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 1179 2006-09-02 19:22:23Z vmassol $

Constructor Summary
AbstractInstalledLocalContainer(LocalConfiguration configuration)
          Default constructor.
 
Method Summary
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()
          
 FileHandler getFileHandler()
           
 java.lang.String getHome()
          
protected  HttpUtils getHttpUtils()
           
protected  JdkUtils getJdkUtils()
           
protected  ResourceUtils getResourceUtils()
           
 java.util.Map getSystemProperties()
          
 ContainerType getType()
          
 void setExtraClasspath(java.lang.String[] classpath)
          
 void setFileHandler(FileHandler fileHandler)
           
 void setHome(java.lang.String home)
          
 void setLogger(Logger logger)
          Overriden in order to set the logger on ancillary components.
 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, getOutput, getState, getTimeout, isAppend, setAppend, setConfiguration, 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, setConfiguration
 
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

getFileHandler

public FileHandler getFileHandler()
Returns:
the Cargo file utility class

setFileHandler

public void setFileHandler(FileHandler fileHandler)
Parameters:
fileHandler - the Cargo file utility class to use. This method is useful for unit testing with Mock objects as it can be passed a test file handler that doesn't perform any real file action.

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()

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()

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()


Copyright © 2004-2011 Codehaus. All Rights Reserved.