1 25 26 package org.objectweb.jonas.ant; 27 28 import java.io.File ; 29 import java.util.ArrayList ; 30 import java.util.Iterator ; 31 import java.util.List ; 32 33 import org.apache.tools.ant.BuildException; 34 import org.apache.tools.ant.Project; 35 import org.apache.tools.ant.Task; 36 import org.apache.tools.ant.taskdefs.Copy; 37 import org.apache.tools.ant.types.FileSet; 38 39 import org.objectweb.jonas.ant.jonasbase.BaseTaskItf; 40 import org.objectweb.jonas.ant.jonasbase.Carol; 41 import org.objectweb.jonas.ant.jonasbase.Db; 42 import org.objectweb.jonas.ant.jonasbase.Dbm; 43 import org.objectweb.jonas.ant.jonasbase.Discovery; 44 import org.objectweb.jonas.ant.jonasbase.JdbcRa; 45 import org.objectweb.jonas.ant.jonasbase.Jms; 46 import org.objectweb.jonas.ant.jonasbase.Lib; 47 import org.objectweb.jonas.ant.jonasbase.Mail; 48 import org.objectweb.jonas.ant.jonasbase.Services; 49 import org.objectweb.jonas.ant.jonasbase.Tasks; 50 import org.objectweb.jonas.ant.jonasbase.WebContainer; 51 import org.objectweb.jonas.ant.jonasbase.wsdl.WsdlPublish; 52 53 58 public class JOnASBaseTask extends Task { 59 60 63 public static final String JONAS_CONF_FILE = "jonas.properties"; 64 65 68 public static final String JORAM_CONF_FILE = "a3servers.xml"; 69 70 73 public static final String JORAM_ADMIN_CONF_FILE = "joram-admin.cfg"; 74 75 78 public static final String CAROL_CONF_FILE = "carol.properties"; 79 80 83 public static final String TOMCAT_CONF_FILE = "server.xml"; 84 85 88 public static final String JETTY_CONF_FILE = "jetty5.xml"; 89 90 93 public static final String P6SPY_CONF_FILE = "spy.properties"; 94 95 98 public static final String [] WARS_LIST = new String [] {"juddi.war", "autoload/jonasAdmin.war"}; 99 100 103 public static final String [] RARS_LIST = new String [] {"autoload/JOnAS_jdbcCP.rar", "autoload/JOnAS_jdbcDM.rar", "autoload/JOnAS_jdbcDS.rar", "autoload/JOnAS_jdbcXA.rar", "autoload/joram_for_jonas_ra.rar"}; 104 105 108 public static final String [] EJBJARS_LIST = new String [] {""}; 109 110 113 public static final String [] APPS_LIST = new String [] {"autoload/mejb.ear"}; 114 115 116 119 private File jonasRoot = null; 120 121 124 private File destDir = null; 125 126 129 private boolean onlyUpdate = false; 130 131 134 private List tasks = null; 135 136 139 public JOnASBaseTask() { 140 tasks = new ArrayList (); 141 } 142 143 147 public void execute() { 148 if (jonasRoot == null) { 149 throw new BuildException("jonasRoot element is not set"); 150 } 151 152 if (destDir == null) { 153 throw new BuildException("destDir element is not set"); 154 } 155 156 if (jonasRoot.getPath().equals(destDir.getPath())) { 157 throw new BuildException("jonasRoot and destDir is the same path !"); 158 } 159 160 File jprops = new File (destDir.getPath() + File.separator + "conf" + File.separator + "jonas.properties"); 161 162 if (onlyUpdate) { 163 if (jprops.exists()) { 164 log("Only updating JONAS_BASE in the directory '" + destDir + "' from source directory '" + jonasRoot + "'", 165 Project.MSG_INFO); 166 JOnASAntTool.updateJonasBase(this, jonasRoot, destDir); 167 return; 168 } else { 169 throw new BuildException("JOnAS base directory '" + destDir.getPath() + "' doesn't exists. Cannot update."); 170 } 171 } 172 173 log("Creating JONAS_BASE in the directory '" + destDir + "' from source directory '" + jonasRoot + "'", 175 Project.MSG_INFO); 176 Copy copy = new Copy(); 177 JOnASAntTool.configure(this, copy); 178 copy.setTodir(destDir); 179 FileSet fileSet = new FileSet(); 180 fileSet.setDir(new File (new File (jonasRoot, "templates"), "conf")); 181 copy.addFileset(fileSet); 182 copy.setOverwrite(true); 183 copy.execute(); 184 185 for (Iterator it = tasks.iterator(); it.hasNext();) { 186 BaseTaskItf task = (BaseTaskItf) it.next(); 187 task.setDestDir(destDir); 188 task.setJonasRoot(jonasRoot); 189 JOnASAntTool.configure(this, (Task) task); 190 String info = task.getLogInfo(); 191 if (info != null) { 192 log(info, Project.MSG_INFO); 193 } 194 task.execute(); 195 } 196 197 JOnASAntTool.updateJonasBase(this, jonasRoot, destDir); 199 } 200 201 205 public void addTasks(Tasks subTasks) { 206 if (subTasks != null) { 207 for (Iterator it = subTasks.getTasks().iterator(); it.hasNext();) { 208 tasks.add(it.next()); 209 } 210 } 211 } 212 213 217 public void addTask(BaseTaskItf task) { 218 if (task != null) { 219 tasks.add(task); 220 } 221 } 222 223 227 public void addConfiguredServices(Services servicesTasks) { 228 addTask(servicesTasks); 229 } 230 231 235 public void addConfiguredJms(Jms jmsTasks) { 236 addTasks(jmsTasks); 237 } 238 239 243 public void addConfiguredJdbcRa(JdbcRa jdbcRaTask) { 244 addTask(jdbcRaTask); 245 } 246 247 251 public void addConfiguredMail(Mail mailTask) { 252 addTask(mailTask); 253 } 254 255 259 public void addConfiguredDb(Db dbTask) { 260 addTask(dbTask); 261 } 262 263 267 public void addConfiguredDbm(Dbm dbTask) { 268 addTask(dbTask); 269 } 270 274 public void addConfiguredLib(Lib libTask) { 275 addTask(libTask); 276 } 277 278 282 public void addConfiguredWsdlPublish(WsdlPublish wsdlTask) { 283 addTask(wsdlTask); 284 } 285 286 290 public void addConfiguredCarol(Carol carolTasks) { 291 addTasks(carolTasks); 292 } 293 294 298 public void addConfiguredDiscovery(Discovery discoveryTasks) { 299 addTasks(discoveryTasks); 300 } 301 302 306 public void addConfiguredWebContainer(WebContainer webContainerTasks) { 307 addTasks(webContainerTasks); 308 } 309 310 314 public void setDestDir(File destDir) { 315 this.destDir = destDir; 316 } 317 318 322 public void setJonasRoot(File jonasRoot) { 323 this.jonasRoot = jonasRoot; 324 } 325 326 330 public void setUpdate(boolean onlyUpdate) { 331 this.onlyUpdate = onlyUpdate; 332 } 333 334 } | Popular Tags |