1 26 27 package org.objectweb.jonas.ant; 28 29 import org.apache.tools.ant.BuildException; 30 import org.apache.tools.ant.taskdefs.Java; 31 32 36 public class JOnASTask extends BootstrapTask { 37 38 41 private static final String START_CLASS = "org.objectweb.jonas.server.Server"; 42 43 46 private static final String ADMIN_CLASS = "org.objectweb.jonas.adm.JonasAdmin"; 47 48 51 private static final String CHECKENV_CLASS = "org.objectweb.jonas.tools.CheckEnv"; 52 53 56 private static final String VERSION_CLASS = "org.objectweb.jonas_lib.version.Version"; 57 58 61 private static final int START_MODE = 0; 62 63 66 private static final int STOP_MODE = 1; 67 68 71 private static final int JNDI_MODE = 2; 72 73 76 private static final int CHECK_MODE = 3; 77 78 81 private static final int VERSION_MODE = 4; 82 83 86 private static final int PING_MODE = 5; 87 88 91 private static final int DEFAULT_MODE = START_MODE; 92 93 96 private String mode = null; 97 98 102 public void execute() { 103 int userMode = DEFAULT_MODE; 104 105 if (mode.equalsIgnoreCase("start")) { 106 userMode = START_MODE; 107 } else if (mode.equalsIgnoreCase("stop")) { 108 userMode = STOP_MODE; 109 } else if (mode.equalsIgnoreCase("jndi")) { 110 userMode = JNDI_MODE; 111 } else if (mode.equalsIgnoreCase("check")) { 112 userMode = CHECK_MODE; 113 } else if (mode.equalsIgnoreCase("version")) { 114 userMode = VERSION_MODE; 115 } else if (mode.equalsIgnoreCase("ping")) { 116 userMode = PING_MODE; 117 } else { 118 throw new BuildException("The mode '" + mode + "' is invalid."); 119 } 120 121 Java bootstrapTask = null; 123 switch (userMode) { 124 default: 125 case START_MODE: 126 bootstrapTask = getBootstraptask(START_CLASS); 127 break; 128 case STOP_MODE: 129 bootstrapTask = getBootstraptask(ADMIN_CLASS); 130 bootstrapTask.createArg().setValue("-s"); 131 break; 132 case JNDI_MODE: 133 bootstrapTask = getBootstraptask(ADMIN_CLASS); 134 bootstrapTask.createArg().setValue("-j"); 135 break; 136 case CHECK_MODE: 137 bootstrapTask = getBootstraptask(CHECKENV_CLASS); 138 break; 139 case VERSION_MODE: 140 bootstrapTask = getBootstraptask(VERSION_CLASS); 141 break; 142 case PING_MODE: 143 bootstrapTask = getBootstraptask(ADMIN_CLASS); 144 bootstrapTask.createArg().setValue("-ping"); 145 break; 146 } 147 148 bootstrapTask.executeJava(); 149 150 } 151 152 155 public String getMode() { 156 return mode; 157 } 158 159 163 public void setMode(String mode) { 164 this.mode = mode; 165 } 166 } | Popular Tags |