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.TaskAnt task wrapper around the Cargo API to start/stop containers. This task is generic and can be used with any container implementation that implements theContainerinterface (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 voidaddConfiguredSysproperty(org.apache.tools.ant.types.Environment.Variable property)Called by Ant when the Variable object has been properly initialized.voidaddConfiguredSyspropertyset(PropertySet propertySet)Adds a set of properties that will be used as system properties in the executing container VM.voidaddSysproperty(org.apache.tools.ant.types.Environment.Variable property)Adds a system property that will be set up in the executing container VM.ConfigurationElementcreateConfiguration()DaemonElementcreateDaemon()org.apache.tools.ant.types.PathcreateExtraClasspath()Adds extra classpath that will be used for starting the container.org.apache.tools.ant.types.PathcreateSharedClasspath()Adds shared classpath that will be shared by container applications.ZipURLInstallerElementcreateZipURLInstaller()voidexecute()protected voidexecuteActions()Execute the action specified by the user.protected StringgetAction()protected ConfigurationElementgetConfiguration()protected ContainergetContainer()protected ClassgetContainerClass()protected StringgetContainerId()protected DaemonElementgetDaemon()protected org.apache.tools.ant.types.PathgetExtraClasspath()protected StringgetHome()protected StringgetId()protected FilegetLog()protected LoggergetLogger()protected LogLevelgetLogLevel()protected StringgetOutput()protected org.apache.tools.ant.types.ReferencegetRefid()protected org.apache.tools.ant.types.PathgetSharedClasspath()protected Map<String,String>getSystemProperties()protected FilegetSystemPropertiesFile()protected longgetTimeout()protected ZipURLInstallerElementgetZipURLInstaller()protected booleanisAppend()protected ContainermakeContainer()voidsetAction(String action)Sets the action to execute ("start", "stop", etc.).voidsetAppend(boolean isAppend)voidsetClass(Class containerClass)voidsetContainerFactory(ContainerFactory containerFactory)voidsetContainerId(String containerId)voidsetHome(String home)Sets the home dir.voidsetId(String id)voidsetLog(File log)voidsetLogLevel(String logLevel)voidsetOutput(String output)voidsetRefId(org.apache.tools.ant.types.Reference refid)voidsetSystemPropertiesFile(File systemPropertiesFile)voidsetTimeout(long timeout)voidsetType(ContainerType type)protected voidsetupExtraClasspath()Set up extra classpaths if defined.protected voidsetupHome()Set up a home dir (possibly using a ZipURLInstaller).protected voidsetupLogger()Set up a logger for the container.protected voidsetupOutput()Set up an output file containing container's console output if defined.protected voidsetupSharedClasspath()Set up shared classpath if defined.protected voidsetupSystemProperties()Set up system properties if defined.protected voidsetupTimeout()Set up a timeout if defined.protected voidwaitDeployableMonitor(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
ZipURLInstallerElementelement
-
createConfiguration
public ConfigurationElement createConfiguration()
- Returns:
- the configured
ConfigurationElementelement
-
createDaemon
public DaemonElement createDaemon()
- Returns:
- the configured
DaemonElementelement
-
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:
executein 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-trueif container is starting (i.e., wait for deployment),falseotherwise.
-
-