📄 startjbosstask.java
字号:
package org.jbpm.ant;
import java.io.*;
import org.apache.tools.ant.*;
public class StartJBossTask extends Task {
private static final String END_MESSAGE = " Started in ";
public void setLog( boolean log ) {
this.log = log;
}
public void execute() throws BuildException {
try {
Thread launcher = new Launcher();
launcher.start();
launcher.join();
} catch (Throwable t) {
t.printStackTrace();
}
}
public class Launcher extends Thread {
public void run() {
try {
String fileSeparator = System.getProperty( "file.separator" );
String jbossHome = getProject().getProperty( "jboss.home" );
String os = getProject().getProperty( "os.name" ).toLowerCase();
String command = null;
if ( os.indexOf( "windows" ) != -1 ) {
command = jbossHome + fileSeparator + "bin" + fileSeparator + "run.bat -c " +
getProject().getProperty("jboss.configuration");
} else if ( os.indexOf( "linux" ) != -1 ) {
command = jbossHome + fileSeparator + "bin" + fileSeparator + "run.sh -c " +
getProject().getProperty("jboss.configuration");
} else {
throw new BuildException( "os '" + os + "' not supported in the startjboss task." );
}
log( "starting jboss with command '" + command + "'" );
Process process = Runtime.getRuntime().exec( command );
BufferedReader reader = new BufferedReader( new InputStreamReader( process.getInputStream() ) );
String line = "";
while ( line.indexOf( END_MESSAGE ) == -1 ) {
line = reader.readLine();
if (log) log( line );
}
log( "jboss started." );
} catch (Throwable t) {
t.printStackTrace();
}
}
}
private boolean log = false;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -