當前位置: 首頁>>代碼示例>>Java>>正文


Java Executor.setProcessDestroyer方法代碼示例

本文整理匯總了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;
}
 
開發者ID:polygOnetic,項目名稱:guetzliconverter,代碼行數:19,代碼來源:ProcessExecutor.java

示例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;
}
 
開發者ID:emanuelecasadio,項目名稱:CliDispatcher,代碼行數:24,代碼來源:ProcessExecutor.java

示例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;
}
 
開發者ID:axonivy,項目名稱:project-build-plugin,代碼行數:14,代碼來源:EngineControl.java

示例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);
  }
}
 
開發者ID:gatling,項目名稱:gatling-maven-plugin,代碼行數:48,代碼來源:Fork.java


注:本文中的org.apache.commons.exec.Executor.setProcessDestroyer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。