Package org.codehaus.cargo.container.spi
Class AbstractInstalledLocalContainer
- java.lang.Object
-
- org.codehaus.cargo.util.log.LoggedObject
-
- org.codehaus.cargo.container.spi.AbstractContainer
-
- org.codehaus.cargo.container.spi.AbstractLocalContainer
-
- org.codehaus.cargo.container.spi.AbstractInstalledLocalContainer
-
- All Implemented Interfaces:
Container,InstalledLocalContainer,RunnableContainer,SpawnedContainer,LocalContainer,Loggable
- Direct Known Subclasses:
AbstractCatalinaInstalledLocalContainer,AbstractGlassFishInstalledLocalContainer,AbstractJBossInstalledLocalContainer,AbstractJonasInstalledLocalContainer,AbstractJRunInstalledLocalContainer,AbstractOc4j10xInstalledLocalContainer,AbstractOrionInstalledLocalContainer,AbstractResinInstalledLocalContainer,AbstractWebLogicInstalledLocalContainer,AbstractWildFlyInstalledLocalContainer,AbstractWildFlySwarmInstalledLocalContainer,Geronimo1xInstalledLocalContainer,JBoss7xInstalledLocalContainer,Jetty6xInstalledLocalContainer,Jo1xInstalledLocalContainer,LibertyInstalledLocalContainer,WebSphere85xInstalledLocalContainer
public abstract class AbstractInstalledLocalContainer extends AbstractLocalContainer implements InstalledLocalContainer
Default container implementation that all local installed container implementations must extend.
-
-
Constructor Summary
Constructors Constructor Description AbstractInstalledLocalContainer(LocalConfiguration configuration)Default constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddExtraClasspath(String location)protected voidaddExtraClasspath(JvmLauncher java)Add extra container classpath entries specified by the user.protected voidaddMemoryArguments(JvmLauncher java)Adds the JVM memory arguments.protected voidaddRuntimeArgs(JvmLauncher java)Add command line arguments to the java command.voidaddSharedClasspath(String location)protected voidaddToolsJarToClasspath(JvmLauncher java)Adds the tools.jar to the classpath, except for Mac OSX and Java 9 or above - As these JVMs do not need the tools.jar.protected JvmLaunchercreateJvmLauncher(boolean server)Creates a preinitialized instance of a JVM launcher to be used for starting, stopping and controlling the container.protected abstract voiddoStart(JvmLauncher java)Implementation ofRunnableContainer.start()that all containers extending this class must implement.protected abstract voiddoStop(JvmLauncher java)Implementation ofRunnableContainer.stop()that all containers extending this class must implement.protected voidforceStopInternal()Some containers may not fully stop and need to be forcibly stopped.String[]getExtraClasspath()StringgetHome()protected HttpUtilsgetHttpUtils()protected StringgetJavaHome()Gets the Java home directory to use for this container.JvmLauncherFactorygetJvmLauncherFactory()Gets the factory used to spawn the container JVM.protected ResourceUtilsgetResourceUtils()String[]getSharedClasspath()Map<String,String>getSystemProperties()ContainerTypegetType()voidifPresentAddPathToList(String location, List<String> list)adds the location to the list, if the file exists.voidsetExtraClasspath(String[] classpath)voidsetHome(String home)voidsetJvmLauncherFactory(JvmLauncherFactory jvmLauncherFactory)Sets the factory used to spawn the container JVM.voidsetJvmToLaunchContainerIn(JvmLauncher java)Determines which java virtual machine will run the container.voidsetLogger(Logger logger)Overriden in order to set the logger on ancillary components.voidsetSharedClasspath(String[] classpath)voidsetSystemProperties(Map<String,String> properties)protected voidstartInternal()Installed and Embedded containers do not have the same signature for theirdoStartmethod.protected voidstopInternal()Installed and Embedded containers do not have the same signature for theirdoStopmethod.protected voidverify()Verify required properties have been set before executing any action.-
Methods inherited from class org.codehaus.cargo.container.spi.AbstractLocalContainer
executePostStartTasks, getConfiguration, getFileHandler, getOutput, getState, getTimeout, isAppend, restart, setAppend, setConfiguration, setFileHandler, setOutput, setState, setTimeout, start, stop, waitForCompletion, waitForPortShutdown, waitForStarting
-
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.Container
getCapability, getId, getName, getState
-
Methods inherited from interface org.codehaus.cargo.container.LocalContainer
getConfiguration, getFileHandler, setConfiguration, setFileHandler
-
Methods inherited from interface org.codehaus.cargo.container.internal.RunnableContainer
getOutput, getTimeout, isAppend, restart, 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 callingAbstractLocalContainer.setConfiguration(LocalConfiguration)
-
-
Method Detail
-
setLogger
public void setLogger(Logger logger)
Overriden in order to set the logger on ancillary components.- Specified by:
setLoggerin interfaceLoggable- Overrides:
setLoggerin classLoggedObject- Parameters:
logger- the logger to set and set in the ancillary objects
-
getHttpUtils
protected final HttpUtils getHttpUtils()
- Returns:
- the HTTP utility class
-
getResourceUtils
protected final ResourceUtils getResourceUtils()
- Returns:
- the Resource utility class
-
setHome
public void setHome(String home)
- Specified by:
setHomein interfaceInstalledLocalContainer- 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. IMPORTANT: While some containers can deal with this parameter being set as a relative path, some others require this path to be set to an absolute directory. Please refer to the documentation of the server to ensure you give the path in the appropriate way. If in doubt, you can use absolute paths -that is known to work with all containers.
-
setSystemProperties
public void setSystemProperties(Map<String,String> properties)
- Specified by:
setSystemPropertiesin interfaceSpawnedContainer- Parameters:
properties- the System properties to set in the container executing VM.
-
getSystemProperties
public Map<String,String> getSystemProperties()
- Specified by:
getSystemPropertiesin interfaceSpawnedContainer- Returns:
- the System properties to set in the container executing VM.
-
setExtraClasspath
public void setExtraClasspath(String[] classpath)
- Specified by:
setExtraClasspathin interfaceSpawnedContainer- Parameters:
classpath- the extra classpath that is added to the container's classpath when it is started.
-
getExtraClasspath
public String[] getExtraClasspath()
- Specified by:
getExtraClasspathin interfaceSpawnedContainer- Returns:
- the extra classpath that is added to the container's classpath when it is started.
-
setSharedClasspath
public void setSharedClasspath(String[] classpath)
- Specified by:
setSharedClasspathin interfaceSpawnedContainer- Parameters:
classpath- the shared classpath that is shared by the container applications.
-
getSharedClasspath
public String[] getSharedClasspath()
- Specified by:
getSharedClasspathin interfaceSpawnedContainer- Returns:
- the extra classpath that is shared by the container applications.
-
getHome
public String getHome()
- Specified by:
getHomein interfaceInstalledLocalContainer- 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.
-
getJvmLauncherFactory
public JvmLauncherFactory getJvmLauncherFactory()
Gets the factory used to spawn the container JVM.- Specified by:
getJvmLauncherFactoryin interfaceSpawnedContainer- Returns:
- The factory used to spawn the container JVM, never
null.
-
setJvmLauncherFactory
public void setJvmLauncherFactory(JvmLauncherFactory jvmLauncherFactory)
Sets the factory used to spawn the container JVM.- Specified by:
setJvmLauncherFactoryin interfaceSpawnedContainer- Parameters:
jvmLauncherFactory- The factory used to spawn the container JVM, must not benull.
-
doStart
protected abstract void doStart(JvmLauncher java) throws Exception
Implementation ofRunnableContainer.start()that all containers extending this class must implement.- Parameters:
java- the predefined JVM launcher to use to start the container- Throws:
Exception- if any error is raised during the container start
-
doStop
protected abstract void doStop(JvmLauncher java) throws Exception
Implementation ofRunnableContainer.stop()that all containers extending this class must implement.- Parameters:
java- the predefined JVM launcher to use to stop the container- Throws:
Exception- if any error is raised during the container stop
-
startInternal
protected void startInternal() throws ExceptionInstalled and Embedded containers do not have the same signature for theirdoStartmethod. Thus we need to abstract it.- Specified by:
startInternalin classAbstractLocalContainer- Throws:
Exception- if any error is raised during the container start
-
stopInternal
protected void stopInternal() throws ExceptionInstalled and Embedded containers do not have the same signature for theirdoStopmethod. Thus we need to abstract it.- Specified by:
stopInternalin classAbstractLocalContainer- Throws:
Exception- if any error is raised during the container stop
-
forceStopInternal
protected final void forceStopInternal()
Some containers may not fully stop and need to be forcibly stopped. This method should be overridden for containers that support forcibly stopping the container.- Overrides:
forceStopInternalin classAbstractLocalContainer
-
createJvmLauncher
protected JvmLauncher createJvmLauncher(boolean server)
Creates a preinitialized instance of a JVM launcher to be used for starting, stopping and controlling the container.- Parameters:
server-trueto launch a server process,falseto launch a client/utility process.- Returns:
- The created JVM launcher, never
null.
-
getJavaHome
protected String getJavaHome()
Gets the Java home directory to use for this container.- Returns:
- The Java home directory to use, never
null.
-
setJvmToLaunchContainerIn
public void setJvmToLaunchContainerIn(JvmLauncher 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(JvmLauncher java) throws FileNotFoundException
Adds the tools.jar to the classpath, except for Mac OSX and Java 9 or above - As these JVMs do not need the tools.jar.- Parameters:
java- the JVM launcher to which to add the tools.jar- Throws:
FileNotFoundException- in case the tools.jar file cannot be found
-
addExtraClasspath
protected void addExtraClasspath(JvmLauncher java)
Add extra container classpath entries specified by the user.- Parameters:
java- the java command used to start/stop the container
-
addRuntimeArgs
protected void addRuntimeArgs(JvmLauncher java)
Add command line arguments to the java command.- Parameters:
java- The java command
-
addMemoryArguments
protected void addMemoryArguments(JvmLauncher java)
Adds the JVM memory arguments.- Parameters:
java- the predefined JVM launcher on which to add memory-related arguments
-
verify
protected void verify()
Verify required properties have been set before executing any action.- Overrides:
verifyin classAbstractLocalContainer
-
getType
public ContainerType getType()
-
addExtraClasspath
public void addExtraClasspath(String location)
- Specified by:
addExtraClasspathin interfaceSpawnedContainer- Parameters:
location- the extra classpath that is added to the container's classpath when it is started.
-
addSharedClasspath
public void addSharedClasspath(String location)
- Specified by:
addSharedClasspathin interfaceSpawnedContainer- Parameters:
location- the shared classpath that is added to the container's classpath when it is started.
-
-