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 void
addExtraClasspath(String location)
protected void
addExtraClasspath(JvmLauncher java)
Add extra container classpath entries specified by the user.protected void
addMemoryArguments(JvmLauncher java)
Adds the JVM memory arguments.protected void
addRuntimeArgs(JvmLauncher java)
Add command line arguments to the java command.void
addSharedClasspath(String location)
protected void
addToolsJarToClasspath(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 JvmLauncher
createJvmLauncher(boolean server)
Creates a preinitialized instance of a JVM launcher to be used for starting, stopping and controlling the container.protected abstract void
doStart(JvmLauncher java)
Implementation ofRunnableContainer.start()
that all containers extending this class must implement.protected abstract void
doStop(JvmLauncher java)
Implementation ofRunnableContainer.stop()
that all containers extending this class must implement.protected void
forceStopInternal()
Some containers may not fully stop and need to be forcibly stopped.String[]
getExtraClasspath()
String
getHome()
protected HttpUtils
getHttpUtils()
protected String
getJavaHome()
Gets the Java home directory to use for this container.JvmLauncherFactory
getJvmLauncherFactory()
Gets the factory used to spawn the container JVM.protected ResourceUtils
getResourceUtils()
String[]
getSharedClasspath()
Map<String,String>
getSystemProperties()
ContainerType
getType()
void
ifPresentAddPathToList(String location, List<String> list)
adds the location to the list, if the file exists.void
setExtraClasspath(String[] classpath)
void
setHome(String home)
void
setJvmLauncherFactory(JvmLauncherFactory jvmLauncherFactory)
Sets the factory used to spawn the container JVM.void
setJvmToLaunchContainerIn(JvmLauncher 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(String[] classpath)
void
setSystemProperties(Map<String,String> properties)
protected void
startInternal()
Installed and Embedded containers do not have the same signature for theirdoStart
method.protected void
stopInternal()
Installed and Embedded containers do not have the same signature for theirdoStop
method.protected void
verify()
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:
setLogger
in interfaceLoggable
- Overrides:
setLogger
in 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:
setHome
in 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:
setSystemProperties
in interfaceSpawnedContainer
- Parameters:
properties
- the System properties to set in the container executing VM.
-
getSystemProperties
public Map<String,String> getSystemProperties()
- Specified by:
getSystemProperties
in interfaceSpawnedContainer
- Returns:
- the System properties to set in the container executing VM.
-
setExtraClasspath
public void setExtraClasspath(String[] classpath)
- Specified by:
setExtraClasspath
in interfaceSpawnedContainer
- Parameters:
classpath
- the extra classpath that is added to the container's classpath when it is started.
-
getExtraClasspath
public String[] getExtraClasspath()
- Specified by:
getExtraClasspath
in 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:
setSharedClasspath
in interfaceSpawnedContainer
- Parameters:
classpath
- the shared classpath that is shared by the container applications.
-
getSharedClasspath
public String[] getSharedClasspath()
- Specified by:
getSharedClasspath
in interfaceSpawnedContainer
- Returns:
- the extra classpath that is shared by the container applications.
-
getHome
public String getHome()
- Specified by:
getHome
in 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:
getJvmLauncherFactory
in 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:
setJvmLauncherFactory
in 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 Exception
Installed and Embedded containers do not have the same signature for theirdoStart
method. Thus we need to abstract it.- Specified by:
startInternal
in classAbstractLocalContainer
- Throws:
Exception
- if any error is raised during the container start
-
stopInternal
protected void stopInternal() throws Exception
Installed and Embedded containers do not have the same signature for theirdoStop
method. Thus we need to abstract it.- Specified by:
stopInternal
in 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:
forceStopInternal
in 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
-true
to launch a server process,false
to 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:
verify
in classAbstractLocalContainer
-
getType
public ContainerType getType()
-
addExtraClasspath
public void addExtraClasspath(String location)
- Specified by:
addExtraClasspath
in 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:
addSharedClasspath
in interfaceSpawnedContainer
- Parameters:
location
- the shared classpath that is added to the container's classpath when it is started.
-
-