1 18 19 package org.apache.tools.ant.taskdefs.optional.j2ee; 20 21 import org.apache.tools.ant.BuildException; 22 import org.apache.tools.ant.taskdefs.Java; 23 import org.apache.tools.ant.types.Commandline; 24 25 34 public class GenericHotDeploymentTool extends AbstractHotDeploymentTool { 35 36 private Java java; 37 38 39 private String className; 40 41 42 private static final String [] VALID_ACTIONS = {ACTION_DEPLOY}; 43 44 50 public Commandline.Argument createArg() { 51 return java.createArg(); 52 } 53 54 62 public Commandline.Argument createJvmarg() { 63 return java.createJvmarg(); 64 } 65 66 73 protected boolean isActionValid() { 74 return (getTask().getAction().equals(VALID_ACTIONS[0])); 75 } 76 77 82 public void setTask(ServerDeploy task) { 83 super.setTask(task); 84 java = new Java(task); 85 } 86 87 93 public void deploy() throws BuildException { 94 java.setClassname(className); 95 java.setClasspath(getClasspath()); 96 java.setFork(true); 97 java.setFailonerror(true); 98 java.execute(); 99 } 100 101 106 public void validateAttributes() throws BuildException { 107 super.validateAttributes(); 108 109 if (className == null) { 110 throw new BuildException("The classname attribute must be set"); 111 } 112 } 113 114 121 public void setClassName(String className) { 122 this.className = className; 123 } 124 125 129 public Java getJava() { 130 return java; 131 } 132 133 137 public String getClassName() { 138 return className; 139 } 140 } 141 | Popular Tags |