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

GenericHotDeploymentTool

public class GenericHotDeploymentTool extends AbstractHotDeploymentTool
A generic tool for J2EE server hot deployment.

The simple implementation spawns a JVM with the supplied class name, jvm args, and arguments.

see
org.apache.tools.ant.taskdefs.optional.j2ee.HotDeploymentTool
see
org.apache.tools.ant.taskdefs.optional.j2ee.AbstractHotDeploymentTool
see
org.apache.tools.ant.taskdefs.optional.j2ee.ServerDeploy

Fields Summary
private org.apache.tools.ant.taskdefs.Java
java
A Java task used to run the deployment tool
private String
className
The fully qualified class name of the deployment tool
private static final String[]
VALID_ACTIONS
List of valid actions
Constructors Summary
Methods Summary
public Commandline.ArgumentcreateArg()
Add a nested argument element to hand to the deployment tool; optional.

return
A Commandline.Argument object representing the command line argument being passed when the deployment tool is run. IE: "-user=mark", "-password=venture"...


                                              
       
        return java.createArg();
    
public Commandline.ArgumentcreateJvmarg()
Add a nested argment element to hand to the JVM running the deployment tool. Creates a nested arg element.

return
A Commandline.Argument object representing the JVM command line argument being passed when the deployment tool is run. IE: "-ms64m", "-mx128m"...

        return java.createJvmarg();
    
public voiddeploy()
Perform the actual deployment. For this generic implementation, a JVM is spawned using the supplied classpath, classname, JVM args, and command line arguments.

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

        java.setClassname(className);
        java.setClasspath(getClasspath());
        java.setFork(true);
        java.setFailonerror(true);
        java.execute();
    
public java.lang.StringgetClassName()
Get the classname attribute.

return
the classname value.

        return className;
    
public org.apache.tools.ant.taskdefs.JavagetJava()
get the java attribute.

return
the java attribute.

        return java;
    
protected 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. For this generic implementation, the only valid action is "deploy"

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

        return (getTask().getAction().equals(VALID_ACTIONS[0]));
    
public voidsetClassName(java.lang.String className)
The name of the class to execute to perfom deployment; required. Example: "com.foobar.tools.deploy.DeployTool"

param
className The fully qualified class name of the class to perform deployment.

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

param
task An ServerDeploy object representing the parent task.
ant.attribute
ignored="true"

        super.setTask(task);
        java = new Java(task);
    
public voidvalidateAttributes()
Validates the passed in attributes. Ensures the className and arguments attribute have been set.

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

        super.validateAttributes();

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