KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > ant > StartJBossTask


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 JavaDoc END_MESSAGE = " Started in ";
9   
10   private String JavaDoc configuration = null;
11   
12   public void execute() throws BuildException {
13     try {
14       // get some environment variables
15
String JavaDoc fileSeparator = System.getProperty( "file.separator" );
16       String JavaDoc jbossHome = getProject().getProperty( "jboss.home" );
17       String JavaDoc os = getProject().getProperty( "os.name" ).toLowerCase();
18       
19       // build the command string
20
String JavaDoc 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       // launch the command and wait till the END_MESSAGE appears
30
Thread JavaDoc launcher = new Launcher(this, command, END_MESSAGE);
31       launcher.start();
32       launcher.join();
33       
34     } catch (Throwable JavaDoc t) {
35       t.printStackTrace();
36     }
37   }
38   
39   private String JavaDoc getConfigParameter() {
40     if (configuration==null) return "";
41     return "-c "+configuration;
42   }
43
44   public void setConfiguration(String JavaDoc configuration) {
45     this.configuration = configuration;
46   }
47 }
48
Popular Tags