org.codehaus.cargo.container.spi
Class AbstractInstalledLocalContainer

java.lang.Object
  extended by org.codehaus.cargo.util.log.LoggedObject
      extended by org.codehaus.cargo.container.spi.AbstractContainer
          extended by org.codehaus.cargo.container.spi.AbstractLocalContainer
              extended by org.codehaus.cargo.container.spi.AbstractInstalledLocalContainer
All Implemented Interfaces:
Container, InstalledLocalContainer, RunnableContainer, SpawnedContainer, LocalContainer, Loggable

public abstract class AbstractInstalledLocalContainer
extends AbstractLocalContainer
implements InstalledLocalContainer

Default container implementation that all local installed container implementations must extend.

Version:
$Id: AbstractInstalledLocalContainer.java 1914 2009-03-03 19:31:40Z mwringe $

Constructor Summary
AbstractInstalledLocalContainer(LocalConfiguration configuration)
          Default constructor.
 
Method Summary
 void addExtraClasspath(java.lang.String location)
          
 void addSharedClasspath(java.lang.String location)
          
protected  void addToolsJarToClasspath(org.apache.tools.ant.types.Path classpath)
          Adds the tools.jar to the classpath, except for Mac OSX as it is not needed.
protected abstract  void doStart(org.apache.tools.ant.taskdefs.Java java)
          Implementation of RunnableContainer.start() that all containers extending this class must implement.
protected abstract  void doStop(org.apache.tools.ant.taskdefs.Java java)
          Implementation of RunnableContainer.stop() that all containers extending this class must implement.
protected  AntUtils getAntUtils()
           
 java.lang.String[] getExtraClasspath()
          
 java.lang.String getHome()
          
protected  HttpUtils getHttpUtils()
           
protected  JdkUtils getJdkUtils()
           
protected  ResourceUtils getResourceUtils()
           
 java.lang.String[] getSharedClasspath()
          
 java.util.Map getSystemProperties()
          
 ContainerType getType()
          
 void ifPresentAddPathToList(java.lang.String location, java.util.List list)
          adds the location to the list, if the file exists.
 void setExtraClasspath(java.lang.String[] classpath)
          
 void setHome(java.lang.String home)
          
protected  void setJvmToLaunchContainerIn(org.apache.tools.ant.taskdefs.Java java)
          Determines which java virtual machine will run the container.
 void setLogger(Logger logger)
          Overriden in order to set the logger on ancillary components.
 void setSharedClasspath(java.lang.String[] classpath)
          
 void setSystemProperties(java.util.Map properties)
          
protected  void startInternal()
          Installed and Embedded containers do not have the same signature for their doStart method.
protected  void stopInternal()
          Installed and Embedded containers do not have the same signature for their doStop method.
protected  void verify()
          Verify required properties have been set before executing any action.
 
Methods inherited from class org.codehaus.cargo.container.spi.AbstractLocalContainer
getConfiguration, getFileHandler, getOutput, getState, getTimeout, isAppend, setAppend, setConfiguration, setFileHandler, setOutput, setState, setTimeout, start, stop, waitForCompletion
 
Methods inherited from class org.codehaus.cargo.util.log.LoggedObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.codehaus.cargo.container.LocalContainer
getConfiguration, getFileHandler, setConfiguration, setFileHandler
 
Methods inherited from interface org.codehaus.cargo.container.Container
getCapability, getId, getName, getState
 
Methods inherited from interface org.codehaus.cargo.util.log.Loggable
getLogger
 
Methods inherited from interface org.codehaus.cargo.container.internal.RunnableContainer
getOutput, getTimeout, isAppend, setAppend, setOutput, setTimeout, start, stop
 

Constructor Detail

AbstractInstalledLocalContainer

public AbstractInstalledLocalContainer(LocalConfiguration configuration)
Default constructor.

Parameters:
configuration - the configuration to associate to this container. It can be changed later on by calling AbstractLocalContainer.setConfiguration(LocalConfiguration)
Method Detail

setLogger

public void setLogger(Logger logger)
Overriden in order to set the logger on ancillary components.

Specified by:
setLogger in interface Loggable
Overrides:
setLogger in class LoggedObject
Parameters:
logger - the logger to set and set in the ancillary objects
See Also:
Loggable.setLogger(org.codehaus.cargo.util.log.Logger)

getHttpUtils

protected final HttpUtils getHttpUtils()
Returns:
the HTTP utility class

getJdkUtils

protected final JdkUtils getJdkUtils()
Returns:
the JDK utility class

getAntUtils

protected final AntUtils getAntUtils()
Returns:
the Ant utility class

getResourceUtils

protected final ResourceUtils getResourceUtils()
Returns:
the Resource utility class

setHome

public final void setHome(java.lang.String home)

Specified by:
setHome in interface InstalledLocalContainer
Parameters:
home - the directory where the container is installed. Note that we're passing a String instead of a File because we want to leave the possibility of using URIs for specifying the home location.
See Also:
InstalledLocalContainer.setHome(String)

setSystemProperties

public void setSystemProperties(java.util.Map properties)

Specified by:
setSystemProperties in interface SpawnedContainer
Parameters:
properties - the System properties to set in the container executing VM.
See Also:
SpawnedContainer.setSystemProperties(java.util.Map)

getSystemProperties

public java.util.Map getSystemProperties()

Specified by:
getSystemProperties in interface SpawnedContainer
Returns:
the System properties to set in the container executing VM.
See Also:
SpawnedContainer.getSystemProperties()

setExtraClasspath

public void setExtraClasspath(java.lang.String[] classpath)

Specified by:
setExtraClasspath in interface SpawnedContainer
Parameters:
classpath - the extra classpath that is added to the container's classpath when it is started.
See Also:
SpawnedContainer.setExtraClasspath(String[])

getExtraClasspath

public java.lang.String[] getExtraClasspath()

Specified by:
getExtraClasspath in interface SpawnedContainer
Returns:
the extra classpath that is added to the container's classpath when it is started.
See Also:
SpawnedContainer.getExtraClasspath()

setSharedClasspath

public void setSharedClasspath(java.lang.String[] classpath)

Specified by:
setSharedClasspath in interface SpawnedContainer
Parameters:
classpath - the shared classpath that is shared by the container applications.
See Also:
InstalledLocalContainer.getHome()

getSharedClasspath

public java.lang.String[] getSharedClasspath()

Specified by:
getSharedClasspath in interface SpawnedContainer
Returns:
the extra classpath that is shared by the container applications.
See Also:
SpawnedContainer.getSharedClasspath()

getHome

public final java.lang.String getHome()

Specified by:
getHome in interface InstalledLocalContainer
Returns:
the directory where the container is installed. Note that we're returning a String instead of a File because we want to leave the possibility of using URIs for specifying the home location.
See Also:
InstalledLocalContainer.getHome()

doStart

protected abstract void doStart(org.apache.tools.ant.taskdefs.Java java)
                         throws java.lang.Exception
Implementation of RunnableContainer.start() that all containers extending this class must implement.

Parameters:
java - the predefined Ant Java command to use to start the container
Throws:
java.lang.Exception - if any error is raised during the container start

doStop

protected abstract void doStop(org.apache.tools.ant.taskdefs.Java java)
                        throws java.lang.Exception
Implementation of RunnableContainer.stop() that all containers extending this class must implement.

Parameters:
java - the predefined Ant Java command to use to stop the container
Throws:
java.lang.Exception - if any error is raised during the container stop

startInternal

protected final void startInternal()
                            throws java.lang.Exception
Installed and Embedded containers do not have the same signature for their doStart method. Thus we need to abstract it.

Specified by:
startInternal in class AbstractLocalContainer
Throws:
java.lang.Exception - if any error is raised during the container start
See Also:
AbstractLocalContainer.startInternal()

stopInternal

protected final void stopInternal()
                           throws java.lang.Exception
Installed and Embedded containers do not have the same signature for their doStop method. Thus we need to abstract it.

Specified by:
stopInternal in class AbstractLocalContainer
Throws:
java.lang.Exception - if any error is raised during the container stop
See Also:
AbstractLocalContainer.stopInternal()

setJvmToLaunchContainerIn

protected void setJvmToLaunchContainerIn(org.apache.tools.ant.taskdefs.Java java)
Determines which java virtual machine will run the container.

Parameters:
java - the java command that will start the container

addToolsJarToClasspath

protected final void addToolsJarToClasspath(org.apache.tools.ant.types.Path classpath)
                                     throws java.io.FileNotFoundException
Adds the tools.jar to the classpath, except for Mac OSX as it is not needed.

Parameters:
classpath - the classpath object to which to add the tools.jar
Throws:
java.io.FileNotFoundException - in case the tools.jar file cannot be found

verify

protected void verify()
Verify required properties have been set before executing any action.

Overrides:
verify in class AbstractLocalContainer
See Also:
AbstractLocalContainer.verify()

getType

public ContainerType getType()

Specified by:
getType in interface Container
Returns:
the container's type (local , remote, etc)
See Also:
Container.getType()

addExtraClasspath

public void addExtraClasspath(java.lang.String location)

Specified by:
addExtraClasspath in interface SpawnedContainer
Parameters:
location - the extra classpath that is added to the container's classpath when it is started.
See Also:
org.codehaus.cargo.container.SpawnedContainer#addExtraClasspath()

addSharedClasspath

public void addSharedClasspath(java.lang.String location)

Specified by:
addSharedClasspath in interface SpawnedContainer
Parameters:
location - the shared classpath that is added to the container's classpath when it is started.
See Also:
org.codehaus.cargo.container.SpawnedContainer#addSharedClasspath()

ifPresentAddPathToList

public void ifPresentAddPathToList(java.lang.String location,
                                   java.util.List list)
adds the location to the list, if the file exists.

Parameters:
location - path to add to the list
list - where to append this path


Copyright © 2004-2011 Codehaus. All Rights Reserved.