1 18 package org.apache.tools.ant.taskdefs.optional.j2ee; 19 20 import java.io.File ; 21 import org.apache.tools.ant.BuildException; 22 import org.apache.tools.ant.taskdefs.Java; 23 import org.apache.tools.ant.types.Path; 24 25 40 public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements HotDeploymentTool { 41 42 45 protected static final String DEFAULT_ORB = "RMI"; 46 47 50 private static final String JONAS_DEPLOY_CLASS_NAME = "org.objectweb.jonas.adm.JonasAdmin"; 51 52 55 private static final String [] VALID_ACTIONS 56 = {ACTION_DELETE, ACTION_DEPLOY, ACTION_LIST, ACTION_UNDEPLOY, ACTION_UPDATE}; 57 58 61 private File jonasroot; 62 63 66 private String orb = null; 67 68 71 private String davidHost; 72 73 76 private int davidPort; 77 78 79 85 public void setDavidhost(final String inValue) { 86 davidHost = inValue; 87 } 88 89 90 96 public void setDavidport(final int inValue) { 97 davidPort = inValue; 98 } 99 100 101 107 public void setJonasroot(final File inValue) { 108 jonasroot = inValue; 109 } 110 111 112 122 public void setOrb(final String inValue) { 123 orb = inValue; 124 } 125 126 127 132 public Path getClasspath() { 133 134 Path aClassPath = super.getClasspath(); 135 136 if (aClassPath == null) { 137 aClassPath = new Path(getTask().getProject()); 138 } 139 if (orb != null) { 140 String aOrbJar = new File (jonasroot, "lib/" + orb + "_jonas.jar").toString(); 141 String aConfigDir = new File (jonasroot, "config/").toString(); 142 Path aJOnASOrbPath = new Path(aClassPath.getProject(), 143 aOrbJar + File.pathSeparator + aConfigDir); 144 aClassPath.append(aJOnASOrbPath); 145 } 146 return aClassPath; 147 } 148 149 150 163 public void validateAttributes() throws BuildException { 164 166 Java java = getJava(); 167 168 String action = getTask().getAction(); 169 if (action == null) { 170 throw new BuildException("The \"action\" attribute must be set"); 171 } 172 173 if (!isActionValid()) { 174 throw new BuildException("Invalid action \"" + action + "\" passed"); 175 } 176 177 if (getClassName() == null) { 178 setClassName(JONAS_DEPLOY_CLASS_NAME); 179 } 180 181 if (jonasroot == null || jonasroot.isDirectory()) { 182 java.createJvmarg().setValue("-Dinstall.root=" + jonasroot); 183 java.createJvmarg().setValue("-Djava.security.policy=" + jonasroot 184 + "/config/java.policy"); 185 186 if ("DAVID".equals(orb)) { 187 java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBClass" 188 + "=org.objectweb.david.libs.binding.orbs.iiop.IIOPORB"); 189 java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBSingletonClass=" 190 + "org.objectweb.david.libs.binding.orbs.ORBSingletonClass"); 191 java.createJvmarg().setValue("-Djavax.rmi.CORBA.StubClass=" 192 + "org.objectweb.david.libs.stub_factories.rmi.StubDelegate"); 193 java.createJvmarg().setValue("-Djavax.rmi.CORBA.PortableRemoteObjectClass=" 194 + "org.objectweb.david.libs.binding.rmi.ORBPortableRemoteObjectDelegate"); 195 java.createJvmarg().setValue("-Djavax.rmi.CORBA.UtilClass=" 196 + "org.objectweb.david.libs.helpers.RMIUtilDelegate"); 197 java.createJvmarg().setValue("-Ddavid.CosNaming.default_method=0"); 198 java.createJvmarg().setValue("-Ddavid.rmi.ValueHandlerClass=" 199 + "com.sun.corba.se.internal.io.ValueHandlerImpl"); 200 if (davidHost != null) { 201 java.createJvmarg().setValue("-Ddavid.CosNaming.default_host=" 202 + davidHost); 203 } 204 if (davidPort != 0) { 205 java.createJvmarg().setValue("-Ddavid.CosNaming.default_port=" 206 + davidPort); 207 } 208 } 209 } 210 211 if (getServer() != null) { 212 java.createArg().setLine("-n " + getServer()); 213 } 214 215 if (action.equals(ACTION_DEPLOY) 216 || action.equals(ACTION_UPDATE) 217 || action.equals("redeploy")) { 218 java.createArg().setLine("-a " + getTask().getSource()); 219 } else if (action.equals(ACTION_DELETE) || action.equals(ACTION_UNDEPLOY)) { 220 java.createArg().setLine("-r " + getTask().getSource()); 221 } else if (action.equals(ACTION_LIST)) { 222 java.createArg().setValue("-l"); 223 } 224 } 225 226 227 236 protected boolean isActionValid() { 237 boolean valid = false; 238 239 String action = getTask().getAction(); 240 241 for (int i = 0; i < VALID_ACTIONS.length; i++) { 242 if (action.equals(VALID_ACTIONS[i])) { 243 valid = true; 244 break; 245 } 246 } 247 248 return valid; 249 } 250 } 251 252 | Popular Tags |