1 package org.jbpm.ant; 2 3 import org.apache.tools.ant.BuildException; 4 import org.apache.tools.ant.Task; 5 6 public class StartJBossTask extends Task { 7 8 private static final String END_MESSAGE = " Started in "; 9 10 private String configuration = null; 11 12 public void execute() throws BuildException { 13 try { 14 String fileSeparator = System.getProperty( "file.separator" ); 16 String jbossHome = getProject().getProperty( "jboss.home" ); 17 String os = getProject().getProperty( "os.name" ).toLowerCase(); 18 19 String command = null; 21 if ( os.indexOf( "windows" ) != -1 ) { 22 command = jbossHome + fileSeparator + "bin" + fileSeparator + "run.bat " + getConfigParameter(); 23 } else if ( os.indexOf( "linux" ) != -1 ) { 24 command = jbossHome + fileSeparator + "bin" + fileSeparator + "run.sh " + getConfigParameter(); 25 } else { 26 throw new BuildException( "os '" + os + "' not supported in the startjboss task." ); 27 } 28 29 Thread launcher = new Launcher(this, command, END_MESSAGE); 31 launcher.start(); 32 launcher.join(); 33 34 } catch (Throwable t) { 35 t.printStackTrace(); 36 } 37 } 38 39 private String getConfigParameter() { 40 if (configuration==null) return ""; 41 return "-c "+configuration; 42 } 43 44 public void setConfiguration(String configuration) { 45 this.configuration = configuration; 46 } 47 } 48 | Popular Tags |