Package org.codehaus.cargo.ant
Class CargoTask
- java.lang.Object
-
- org.apache.tools.ant.ProjectComponent
-
- org.apache.tools.ant.Task
-
- org.codehaus.cargo.ant.CargoTask
-
- All Implemented Interfaces:
Cloneable
public class CargoTask extends org.apache.tools.ant.Task
Ant task wrapper around the Cargo API to start/stop containers. This task is generic and can be used with any container implementation that implements theContainer
interface (either the implementations provided by Cargo or your own ones).
-
-
Constructor Summary
Constructors Constructor Description CargoTask()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConfiguredSysproperty(org.apache.tools.ant.types.Environment.Variable property)
Called by Ant when the Variable object has been properly initialized.void
addConfiguredSyspropertyset(PropertySet propertySet)
Adds a set of properties that will be used as system properties in the executing container VM.void
addSysproperty(org.apache.tools.ant.types.Environment.Variable property)
Adds a system property that will be set up in the executing container VM.ConfigurationElement
createConfiguration()
DaemonElement
createDaemon()
org.apache.tools.ant.types.Path
createExtraClasspath()
Adds extra classpath that will be used for starting the container.org.apache.tools.ant.types.Path
createSharedClasspath()
Adds shared classpath that will be shared by container applications.ZipURLInstallerElement
createZipURLInstaller()
void
execute()
protected void
executeActions()
Execute the action specified by the user.protected String
getAction()
protected ConfigurationElement
getConfiguration()
protected Container
getContainer()
protected Class
getContainerClass()
protected String
getContainerId()
protected DaemonElement
getDaemon()
protected org.apache.tools.ant.types.Path
getExtraClasspath()
protected String
getHome()
protected String
getId()
protected File
getLog()
protected Logger
getLogger()
protected LogLevel
getLogLevel()
protected String
getOutput()
protected org.apache.tools.ant.types.Reference
getRefid()
protected org.apache.tools.ant.types.Path
getSharedClasspath()
protected Map<String,String>
getSystemProperties()
protected File
getSystemPropertiesFile()
protected long
getTimeout()
protected ZipURLInstallerElement
getZipURLInstaller()
protected boolean
isAppend()
protected Container
makeContainer()
void
setAction(String action)
Sets the action to execute ("start", "stop", etc.).void
setAppend(boolean isAppend)
void
setClass(Class containerClass)
void
setContainerFactory(ContainerFactory containerFactory)
void
setContainerId(String containerId)
void
setHome(String home)
Sets the home dir.void
setId(String id)
void
setLog(File log)
void
setLogLevel(String logLevel)
void
setOutput(String output)
void
setRefId(org.apache.tools.ant.types.Reference refid)
void
setSystemPropertiesFile(File systemPropertiesFile)
void
setTimeout(long timeout)
void
setType(ContainerType type)
protected void
setupExtraClasspath()
Set up extra classpaths if defined.protected void
setupHome()
Set up a home dir (possibly using a ZipURLInstaller).protected void
setupLogger()
Set up a logger for the container.protected void
setupOutput()
Set up an output file containing container's console output if defined.protected void
setupSharedClasspath()
Set up shared classpath if defined.protected void
setupSystemProperties()
Set up system properties if defined.protected void
setupTimeout()
Set up a timeout if defined.protected void
waitDeployableMonitor(boolean starting)
Waits until all deployables with a deployable monitor are deployed / undeployed.-
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
-
-
-
-
Method Detail
-
setClass
public void setClass(Class containerClass)
- Parameters:
containerClass
- the container implementation class to use
-
getContainerClass
protected final Class getContainerClass()
- Returns:
- Container class.
-
setAction
public void setAction(String action)
Sets the action to execute ("start", "stop", etc.).- Parameters:
action
- the action that will be executed by this task
-
setContainerId
public void setContainerId(String containerId)
- Parameters:
containerId
- the container id
-
setType
public void setType(ContainerType type)
- Parameters:
type
- the container's type (e.g. "installed", "embedded" or "remote")
-
setHome
public void setHome(String home)
Sets the home dir.- Parameters:
home
- home dir to set.
-
setId
public void setId(String id)
- Parameters:
id
- the Ant property name that will contain the container instance reference
-
setRefId
public void setRefId(org.apache.tools.ant.types.Reference refid)
- Parameters:
refid
- the Ant property name that contains an existing container instance reference
-
createZipURLInstaller
public ZipURLInstallerElement createZipURLInstaller()
- Returns:
- the configured
ZipURLInstallerElement
element
-
createConfiguration
public ConfigurationElement createConfiguration()
- Returns:
- the configured
ConfigurationElement
element
-
createDaemon
public DaemonElement createDaemon()
- Returns:
- the configured
DaemonElement
element
-
setOutput
public void setOutput(String output)
- Parameters:
output
- Output file name to set.
-
setLog
public void setLog(File log)
- Parameters:
log
- Logger to set.
-
setLogLevel
public void setLogLevel(String logLevel)
- Parameters:
logLevel
- Log level to set.- See Also:
AbstractLogger.setLevel(org.codehaus.cargo.util.log.LogLevel)
-
setAppend
public void setAppend(boolean isAppend)
- Parameters:
isAppend
- Whether to append logs.- See Also:
RunnableContainer.setAppend(boolean)
-
setTimeout
public void setTimeout(long timeout)
- Parameters:
timeout
- Container timeout to set.- See Also:
RunnableContainer.setTimeout(long)
-
createExtraClasspath
public org.apache.tools.ant.types.Path createExtraClasspath()
Adds extra classpath that will be used for starting the container.- Returns:
- reference to the classpath
-
createSharedClasspath
public org.apache.tools.ant.types.Path createSharedClasspath()
Adds shared classpath that will be shared by container applications.- Returns:
- reference to the classpath
-
addSysproperty
public void addSysproperty(org.apache.tools.ant.types.Environment.Variable property)
Adds a system property that will be set up in the executing container VM.- Parameters:
property
- the system property to add
-
setSystemPropertiesFile
public void setSystemPropertiesFile(File systemPropertiesFile)
- Parameters:
systemPropertiesFile
- System properties loaded from file.
-
addConfiguredSyspropertyset
public void addConfiguredSyspropertyset(PropertySet propertySet)
Adds a set of properties that will be used as system properties in the executing container VM. Note: When we switch to Ant 1.6 we will be able to replace this by Ant 1.6 PropertySet- Parameters:
propertySet
- Ant element defining the property set
-
addConfiguredSysproperty
public void addConfiguredSysproperty(org.apache.tools.ant.types.Environment.Variable property)
Called by Ant when the Variable object has been properly initialized.- Parameters:
property
- the system property to set
-
execute
public void execute()
- Overrides:
execute
in classorg.apache.tools.ant.Task
-
executeActions
protected void executeActions()
Execute the action specified by the user.
-
setupLogger
protected void setupLogger()
Set up a logger for the container.
-
setupOutput
protected void setupOutput()
Set up an output file containing container's console output if defined.
-
setupTimeout
protected void setupTimeout()
Set up a timeout if defined.
-
setupHome
protected void setupHome()
Set up a home dir (possibly using a ZipURLInstaller).
-
setupExtraClasspath
protected void setupExtraClasspath()
Set up extra classpaths if defined.
-
setupSharedClasspath
protected void setupSharedClasspath()
Set up shared classpath if defined.
-
setupSystemProperties
protected void setupSystemProperties()
Set up system properties if defined.
-
getSystemProperties
protected final Map<String,String> getSystemProperties()
- Returns:
- System properties.
- See Also:
addSysproperty(Environment.Variable)
-
getSystemPropertiesFile
protected File getSystemPropertiesFile()
- Returns:
- System properties loaded from file.
-
getZipURLInstaller
protected final ZipURLInstallerElement getZipURLInstaller()
- Returns:
- ZIP URL installer.
- See Also:
createZipURLInstaller()
-
getConfiguration
protected final ConfigurationElement getConfiguration()
- Returns:
- Configuration.
- See Also:
createConfiguration()
-
getDaemon
protected final DaemonElement getDaemon()
- Returns:
- Cargo daemon.
- See Also:
createDaemon()
-
getExtraClasspath
protected final org.apache.tools.ant.types.Path getExtraClasspath()
- Returns:
- Extra classpath.
- See Also:
createExtraClasspath()
-
getSharedClasspath
protected final org.apache.tools.ant.types.Path getSharedClasspath()
- Returns:
- Shared classpath.
- See Also:
createSharedClasspath()
-
getTimeout
protected final long getTimeout()
- Returns:
- Container timeout.
- See Also:
RunnableContainer.getTimeout()
-
getOutput
protected final String getOutput()
- Returns:
- Output file name.
- See Also:
setOutput(String)
-
getLog
protected final File getLog()
- Returns:
- Log file name.
- See Also:
setLog(File)
-
getLogLevel
protected LogLevel getLogLevel()
- Returns:
- Log level set.
- See Also:
AbstractLogger.setLevel(org.codehaus.cargo.util.log.LogLevel)
-
getHome
protected final String getHome()
- Returns:
- Container home directory.
-
isAppend
protected final boolean isAppend()
- Returns:
- Whether to append logs.
- See Also:
RunnableContainer.isAppend()
-
getAction
protected final String getAction()
- Returns:
- the action to execute ("start" or "stop")
-
makeContainer
protected Container makeContainer()
- Returns:
- the container instance to start/stop
-
getContainerId
protected String getContainerId()
- Returns:
- Container id.
-
getId
protected String getId()
- Returns:
- Ant property name that contains the container instance reference
-
getRefid
protected org.apache.tools.ant.types.Reference getRefid()
- Returns:
- Ant property name that contains an existing container instance reference
-
setContainerFactory
public void setContainerFactory(ContainerFactory containerFactory)
- Parameters:
containerFactory
- the new container factory to use
-
getContainer
protected Container getContainer()
- Returns:
- the container instance created after the execution of
execute()
-
getLogger
protected Logger getLogger()
- Returns:
- the logger to use to log outputs from the execution of the Ant task
-
waitDeployableMonitor
protected void waitDeployableMonitor(boolean starting)
Waits until all deployables with a deployable monitor are deployed / undeployed.- Parameters:
starting
-true
if container is starting (i.e., wait for deployment),false
otherwise.
-
-