org.apache.cactus.integration.ant.container
Class GenericContainer

java.lang.Object
  extended by org.apache.cactus.container.ContainerWrapper
      extended by org.apache.cactus.integration.ant.container.GenericContainer

public final class GenericContainer
extends ContainerWrapper

A generic container that can be nested in the CactusTask to support complete customization of the container lifecycle from a build file.

Version:
$Id: GenericContainer.java 238811 2004-02-29 10:10:42Z vmassol $

Nested Class Summary
 class GenericContainer.Hook
          Class that represents the nested 'startup' and 'shutdown' elements.
 
Constructor Summary
GenericContainer()
           
 
Method Summary
protected  org.apache.tools.ant.Task createAntTask(java.lang.String theName)
          Creates and returns a new instance of the Ant task mapped to the specified logical name using the org.apache.cactus.integration.ant.util.AntTaskFactory set.
 GenericContainer.Hook createShutDown()
          Creates a nested 'shutdown' element.
 GenericContainer.Hook createStartUp()
          Creates a nested 'startup' element.
 java.lang.String getName()
          
 int getPort()
          Returns the port to which the container should listen.
 boolean isShutDownSet()
          Returns whether a way to start the container has already been set, either as a target, or as a nested task container.
 boolean isStartUpSet()
          Returns whether a way to stop the container has already been set, either as a target, or as a nested task container.
 void setAntTaskFactory(org.codehaus.cargo.util.AntTaskFactory theFactory)
          
 void setName(java.lang.String theName)
          Sets the name of the container for logging purposes.
 void setPort(int thePort)
          Sets the port to which the container should listen.
 void setShutDownTarget(java.lang.String theShutDownTarget)
          Sets the target to call to stop the server.
 void setStartUpTarget(java.lang.String theStartUpTarget)
          Sets the target to call to start the server.
 void shutDown()
          Shuts down the container by delegating to the shutdown hook.
 void startUp()
          Starts up the container by delegating to the startup hook.
 
Methods inherited from class org.apache.cactus.container.ContainerWrapper
getBaseURL, getContainerClasspath, getProtocol, getServer, getStartUpWait, getTestContext, getToDir, init, isEnabled, isExcluded, setContainer, setContainerClasspath, setLogger, setSystemProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericContainer

public GenericContainer()
Method Detail

createStartUp

public GenericContainer.Hook createStartUp()
                                    throws org.apache.tools.ant.BuildException
Creates a nested 'startup' element.

Returns:
The new hook element
Throws:
org.apache.tools.ant.BuildException - If a startup hook has already been added

createShutDown

public GenericContainer.Hook createShutDown()
                                     throws org.apache.tools.ant.BuildException
Creates a nested 'shutdown' element.

Returns:
The new hook element
Throws:
org.apache.tools.ant.BuildException - If a shutdown hook has already been added

isShutDownSet

public boolean isShutDownSet()
Returns whether a way to start the container has already been set, either as a target, or as a nested task container.

Returns:
true if the shut down procedure has been set

isStartUpSet

public boolean isStartUpSet()
Returns whether a way to stop the container has already been set, either as a target, or as a nested task container.

Returns:
true if the start up procedure has been set

setName

public void setName(java.lang.String theName)
Sets the name of the container for logging purposes.

Parameters:
theName - The container name

setPort

public void setPort(int thePort)
Sets the port to which the container should listen.

Parameters:
thePort - The port to set

setStartUpTarget

public void setStartUpTarget(java.lang.String theStartUpTarget)
Sets the target to call to start the server.

Parameters:
theStartUpTarget - the Ant target to call

setShutDownTarget

public void setShutDownTarget(java.lang.String theShutDownTarget)
Sets the target to call to stop the server.

Parameters:
theShutDownTarget - the Ant target to call

getName

public java.lang.String getName()

Overrides:
getName in class ContainerWrapper
See Also:
org.apache.cactus.integration.ant.container.Container#getName

getPort

public int getPort()
Returns the port to which the container should listen.

Overrides:
getPort in class ContainerWrapper
Returns:
The port
See Also:
Container#getPort()

startUp

public void startUp()
             throws org.apache.tools.ant.BuildException
Starts up the container by delegating to the startup hook.

Overrides:
startUp in class ContainerWrapper
Throws:
org.apache.tools.ant.BuildException - If thrown by the startup hook
See Also:
Container#startUp()

shutDown

public void shutDown()
              throws org.apache.tools.ant.BuildException
Shuts down the container by delegating to the shutdown hook.

Overrides:
shutDown in class ContainerWrapper
Throws:
org.apache.tools.ant.BuildException - If thrown by the shutdown hook
See Also:
Container#shutDown()

createAntTask

protected final org.apache.tools.ant.Task createAntTask(java.lang.String theName)
Creates and returns a new instance of the Ant task mapped to the specified logical name using the org.apache.cactus.integration.ant.util.AntTaskFactory set.

Parameters:
theName - The logical name of the task to create
Returns:
A new isntance of the task
See Also:
AntTaskFactory.createTask(java.lang.String)

setAntTaskFactory

public final void setAntTaskFactory(org.codehaus.cargo.util.AntTaskFactory theFactory)

See Also:
Container#setAntTaskFactory


Copyright © 2001-2009 The Apache Software Foundation. All Rights Reserved.