本文整理匯總了Java中org.apache.commons.exec.Executor.setProcessDestroyer方法的典型用法代碼示例。如果您正苦於以下問題:Java Executor.setProcessDestroyer方法的具體用法?Java Executor.setProcessDestroyer怎麽用?Java Executor.setProcessDestroyer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.exec.Executor
的用法示例。
在下文中一共展示了Executor.setProcessDestroyer方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: call
import org.apache.commons.exec.Executor; //導入方法依賴的package包/類
@Override
public Long call() throws Exception {
Executor executor = new DefaultExecutor();
executor.setProcessDestroyer(new ShutdownHookProcessDestroyer());
ExecuteWatchdog watchDog = new ExecuteWatchdog(watchdogTimeout);
executor.setWatchdog(watchDog);
executor.setStreamHandler(new PumpStreamHandler(new MyLogOutputStream(handler, true), new MyLogOutputStream(handler, false)));
Long exitValue;
try {
exitValue = new Long(executor.execute(commandline));
} catch (ExecuteException e) {
exitValue = new Long(e.getExitValue());
}
if (watchDog.killedProcess()) {
exitValue = WATCHDOG_EXIST_VALUE;
}
return exitValue;
}
示例2: call
import org.apache.commons.exec.Executor; //導入方法依賴的package包/類
public Long call() throws Exception {
logger.debug("Started");
Executor executor = new DefaultExecutor();
executor.setProcessDestroyer(new ShutdownHookProcessDestroyer());
ExecuteWatchdog watchDog = new ExecuteWatchdog(watchdogTimeout);
executor.setWatchdog(watchDog);
executor.setStreamHandler(new PumpStreamHandler(new MyLogOutputStream(handler, true),new MyLogOutputStream(handler, false)));
Long exitValue;
try {
logger.debug("Successfully completed");
exitValue = new Long(executor.execute(commandline));
} catch (ExecuteException e) {
logger.debug("Execute exception");
exitValue = new Long(e.getExitValue());
}
if(watchDog.killedProcess()){
logger.debug("Killed by watchdog");
exitValue =WATCHDOG_EXIT_VALUE;
}
return exitValue;
}
示例3: start
import org.apache.commons.exec.Executor; //導入方法依賴的package包/類
public Executor start() throws Exception
{
CommandLine startCmd = toEngineCommand(Command.start);
context.log.info("Start Axon.ivy Engine in folder: " + context.engineDirectory);
Executor executor = createEngineExecutor();
executor.setStreamHandler(createEngineLogStreamForwarder(logLine -> findStartEngineUrl(logLine)));
executor.setWatchdog(new ExecuteWatchdog(ExecuteWatchdog.INFINITE_TIMEOUT));
executor.setProcessDestroyer(new ShutdownHookProcessDestroyer());
executor.execute(startCmd, asynchExecutionHandler());
waitForEngineStart(executor);
return executor;
}
示例4: run
import org.apache.commons.exec.Executor; //導入方法依賴的package包/類
void run() throws Exception {
if (propagateSystemProperties) {
for (Entry<Object, Object> systemProp : System.getProperties().entrySet()) {
String name = systemProp.getKey().toString();
String value = safeWindowsPath(systemProp.getValue().toString());
if (isPropagatableProperty(name)) {
if (name.contains(" ")) {
log.warn("System property name '" + name + "' contains a whitespace and can't be propagated");
} else if (MojoUtils.IS_WINDOWS && value.contains(" ")) {
log.warn("System property value '" + value + "' contains a whitespace and can't be propagated on Windows");
} else {
this.jvmArgs.add("-D" + name + "=" + safe(StringUtils.escape(value)));
}
}
}
}
this.jvmArgs.add("-jar");
if (log.isDebugEnabled()) {
log.debug(StringUtils.join(classpath.iterator(), ",\n"));
}
this.jvmArgs.add(MojoUtils.createBooterJar(classpath, MainWithArgsInFile.class.getName()).getCanonicalPath());
List<String> command = buildCommand();
Executor exec = new DefaultExecutor();
exec.setStreamHandler(new PumpStreamHandler(System.out, System.err, System.in));
exec.setProcessDestroyer(new ShutdownHookProcessDestroyer());
CommandLine cl = new CommandLine(javaExecutable);
for (String arg : command) {
cl.addArgument(arg, false);
}
if (log.isDebugEnabled()) {
log.debug(cl.toString());
}
int exitValue = exec.execute(cl);
if (exitValue != 0) {
throw new MojoFailureException("command line returned non-zero value:" + exitValue);
}
}