org.codehaus.cargo.ant
Class CargoTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.codehaus.cargo.ant.CargoTask
All Implemented Interfaces:
java.lang.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 the Container interface (either the implementations provided by Cargo or your own ones).

Version:
$Id: CargoTask.java 1233 2006-11-22 09:15:56Z vmassol $

Field Summary
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
CargoTask()
           
 
Method Summary
 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()
           
 org.apache.tools.ant.types.Path createExtraClasspath()
          Adds extra classpath that will be used for starting the container.
 ZipURLInstallerElement createZipURLInstaller()
           
 void execute()
           
protected  void executeActions()
          Execute the action specified by the user.
protected  java.lang.String getAction()
           
protected  ConfigurationElement getConfiguration()
          
protected  Container getContainer()
           
protected  java.lang.Class getContainerClass()
          
protected  java.lang.String getContainerId()
          
protected  org.apache.tools.ant.types.Path getExtraClasspath()
          
protected  java.lang.String getHome()
          
protected  java.lang.String getId()
          
protected  java.io.File getLog()
          
protected  Logger getLogger()
           
protected  LogLevel getLogLevel()
          
protected  java.lang.String getOutput()
          
protected  org.apache.tools.ant.types.Reference getRefid()
          
protected  java.util.Map getSystemProperties()
          
protected  long getTimeout()
          
 boolean getWait()
           
protected  ZipURLInstallerElement getZipURLInstaller()
          
protected  boolean isAppend()
          
protected  Container makeContainer()
           
 void setAction(java.lang.String action)
          Sets the action to execute (either "start" or "stop").
 void setAppend(boolean isAppend)
          
 void setClass(java.lang.Class containerClass)
           
 void setContainerFactory(ContainerFactory containerFactory)
           
 void setContainerId(java.lang.String containerId)
           
 void setHint(java.lang.String hint)
          Deprecated. see setType(ContainerType)
 void setHome(java.lang.String home)
          Sets the home dir.
 void setId(java.lang.String id)
           
 void setLog(java.io.File log)
          
 void setLogLevel(java.lang.String logLevel)
          
 void setOutput(java.lang.String output)
          
 void setRefId(org.apache.tools.ant.types.Reference refid)
           
 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 setupSystemProperties()
          Set up system properties if defined.
protected  void setupTimeout()
          Set up a timeout if defined.
 void setWait(boolean wait)
           
 
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
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CargoTask

public CargoTask()
Method Detail

setWait

public void setWait(boolean wait)
Parameters:
wait - if true wait indefinitely after the container is started, if false return the execution flow to the user

getWait

public boolean getWait()
Returns:
whether the task will block execution after the container is started or not

setClass

public final void setClass(java.lang.Class containerClass)
Parameters:
containerClass - the container implementation class to use

getContainerClass

protected final java.lang.Class getContainerClass()

See Also:
setClass(Class)

setAction

public void setAction(java.lang.String action)
Sets the action to execute (either "start" or "stop").

Parameters:
action - the action that will be executed by this task

setContainerId

public void setContainerId(java.lang.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")

setHint

public void setHint(java.lang.String hint)
Deprecated. see setType(ContainerType)

Parameters:
hint - the container's type (e.g. "installed", "embedded" or "remote")

setHome

public final void setHome(java.lang.String home)
Sets the home dir.

Parameters:
home - home dir to set.

setId

public final void setId(java.lang.String id)
Parameters:
id - the Ant property name that will contain the container instance reference

setRefId

public final void setRefId(org.apache.tools.ant.types.Reference refid)
Parameters:
refid - the Ant property name that contains an existing container instance reference

createZipURLInstaller

public final ZipURLInstallerElement createZipURLInstaller()
Returns:
the configured ZipURLInstallerElement element

createConfiguration

public final ConfigurationElement createConfiguration()
Returns:
the configured ConfigurationElement element

setOutput

public final void setOutput(java.lang.String output)

See Also:
RunnableContainer.setOutput(String)

setLog

public final void setLog(java.io.File log)

See Also:
LoggedObject.setLogger(Logger)

setLogLevel

public void setLogLevel(java.lang.String logLevel)

See Also:
AbstractLogger.setLevel(org.codehaus.cargo.util.log.LogLevel)

setAppend

public final void setAppend(boolean isAppend)

See Also:
RunnableContainer.setAppend(boolean)

setTimeout

public void setTimeout(long timeout)

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

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

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 class org.apache.tools.ant.Task
See Also:
Task.execute()

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.


setupSystemProperties

protected void setupSystemProperties()
Set up system properties if defined.


getSystemProperties

protected final java.util.Map getSystemProperties()

See Also:
addSysproperty(Environment.Variable)

getZipURLInstaller

protected final ZipURLInstallerElement getZipURLInstaller()

See Also:
createZipURLInstaller()

getConfiguration

protected final ConfigurationElement getConfiguration()

See Also:
createConfiguration()

getExtraClasspath

protected final org.apache.tools.ant.types.Path getExtraClasspath()

See Also:
createExtraClasspath()

getTimeout

protected final long getTimeout()

See Also:
getTimeout()

getOutput

protected final java.lang.String getOutput()

See Also:
setOutput(String)

getLog

protected final java.io.File getLog()

See Also:
setLog(File)

getLogLevel

protected LogLevel getLogLevel()

See Also:
setLogLevel(String)

getHome

protected final java.lang.String getHome()

See Also:
setHome(String)

isAppend

protected final boolean isAppend()

See Also:
setAppend(boolean)

getAction

protected final java.lang.String getAction()
Returns:
the action to execute ("start" or "stop")

makeContainer

protected Container makeContainer()
Returns:
the container instance to start/stop

getContainerId

protected java.lang.String getContainerId()

See Also:
setContainerId(String)

getId

protected java.lang.String getId()

See Also:
setId(String)

getRefid

protected org.apache.tools.ant.types.Reference getRefid()

See Also:
setRefId(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


Copyright © 2004-2011 Codehaus. All Rights Reserved.