Class 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 the Container interface (either the implementations provided by Cargo or your own ones).
    • Constructor Detail

      • CargoTask

        public CargoTask()
    • 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
      • setOutput

        public void setOutput​(String output)
        Parameters:
        output - Output file name to set.
      • setLog

        public void setLog​(File log)
        Parameters:
        log - Logger to set.
      • 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 class org.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.
      • getSystemPropertiesFile

        protected File getSystemPropertiesFile()
        Returns:
        System properties loaded from file.
      • 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()
      • getLog

        protected final File getLog()
        Returns:
        Log file name.
        See Also:
        setLog(File)
      • getHome

        protected final String getHome()
        Returns:
        Container home directory.
      • 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.