FileDocCategorySizeDatePackage
AbstractHotDeploymentTool.javaAPI DocApache Ant 1.706575Wed Dec 13 06:16:18 GMT 2006org.apache.tools.ant.taskdefs.optional.j2ee

AbstractHotDeploymentTool

public abstract class AbstractHotDeploymentTool extends Object implements HotDeploymentTool
Abstract class to support vendor-specific hot deployment tools. This class will validate boilerplate attributes. Subclassing this class for a vendor specific tool involves the following.
  1. Implement the isActionValid() method to insure the action supplied as the "action" attribute of ServerDeploy is valid.
  2. Implement the validateAttributes() method to insure all required attributes are supplied, and are in the correct format.
  3. Add a add<TOOL> method to the ServerDeploy class. This method will be called when Ant encounters a add<TOOL> task nested in the serverdeploy task.
  4. Define the deploy method. This method should perform whatever task it takes to hot-deploy the component. IE: spawn a JVM and run class, exec a native executable, run Java code...
see
org.apache.tools.ant.taskdefs.optional.j2ee.HotDeploymentTool
see
org.apache.tools.ant.taskdefs.optional.j2ee.ServerDeploy

Fields Summary
private ServerDeploy
task
The parent task
private org.apache.tools.ant.types.Path
classpath
The classpath passed to the JVM on execution.
private String
userName
The username for the deployment server.
private String
password
The password for the deployment server.
private String
server
The address of the deployment server
Constructors Summary
Methods Summary
public org.apache.tools.ant.types.PathcreateClasspath()
Add a classpath as a nested element.

return
A Path object representing the classpath to be used.

        if (classpath == null) {
            classpath = new Path(task.getProject());
        }
        return classpath.createPath();
    
public abstract voiddeploy()
Perform the actual deployment. It's up to the subclasses to implement the actual behavior.

exception
org.apache.tools.ant.BuildException if the attributes are invalid or incomplete.

public org.apache.tools.ant.types.PathgetClasspath()
gets the classpath field.

return
A Path representing the "classpath" attribute.

        return classpath;
    
public java.lang.StringgetPassword()
Returns the password field.

return
A String representing the "password" attribute.

        return password;
    
public java.lang.StringgetServer()
Returns the server field.

return
A String representing the "server" attribute.

        return server;
    
protected ServerDeploygetTask()
Returns the task field, a ServerDeploy object.

return
An ServerDeploy representing the parent task.

        return task;
    
public java.lang.StringgetUserName()
Returns the userName field.

return
A String representing the "userName" attribute.

        return userName;
    
protected abstract booleanisActionValid()
Determines if the "action" attribute defines a valid action.

Subclasses should determine if the action passed in is supported by the vendor's deployment tool.

Actions may by "deploy", "delete", etc... It all depends on the tool.

return
true if the "action" attribute is valid, false if not.

public voidsetClasspath(org.apache.tools.ant.types.Path classpath)
The classpath to be passed to the JVM running the tool; optional depending upon the tool. The classpath may also be supplied as a nested element.

param
classpath A Path object representing the "classpath" attribute.

        this.classpath = classpath;
    
public voidsetPassword(java.lang.String password)
The password of the user; optional.

param
password A String representing the "password" attribute.

        this.password = password;
    
public voidsetServer(java.lang.String server)
The address or URL for the server where the component will be deployed.

param
server A String representing the "server" attribute.

        this.server = server;
    
public voidsetTask(ServerDeploy task)
Sets the parent task.

param
task a ServerDeploy object representing the parent task.
ant.attribute
ignore="true"

        this.task = task;
    
public voidsetUserName(java.lang.String userName)
The user with privileges to deploy applications to the server; optional.

param
userName A String representing the "userName" attribute.

        this.userName = userName;
    
public voidvalidateAttributes()
Validates the passed in attributes. Subclasses should chain to this super-method to insure validation of boilerplate attributes.

Only the "action" attribute is required in the base class. Subclasses should check attributes accordingly.

exception
org.apache.tools.ant.BuildException if the attributes are invalid or incomplete.

        if (task.getAction() == null) {
            throw new BuildException("The \"action\" attribute must be set");
        }

        if (!isActionValid()) {
            throw new BuildException("Invalid action \"" + task.getAction() + "\" passed");
        }

        if (classpath == null) {
            throw new BuildException("The classpath attribute must be set");
        }