org.apache.commons.exec.Executor.getProcessDestroyer()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(1.5k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中org.apache.commons.exec.Executor.getProcessDestroyer()方法的一些代码示例,展示了Executor.getProcessDestroyer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Executor.getProcessDestroyer()方法的具体详情如下:
包路径:org.apache.commons.exec.Executor
类名称:Executor
方法名:getProcessDestroyer

Executor.getProcessDestroyer介绍

[英]Set the handler for cleanup of started processes if the main process is going to terminate.
[中]如果主进程将终止,请设置已启动进程的清理处理程序。

代码示例

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.tools

/** Stop the process that we started, if any, and wait for it to exit before returning */
  public void stop() {
    if(executor == null) {
      throw new IllegalStateException("Process not started, no Executor set");
    }
    final Object d = executor.getProcessDestroyer();
    if(d instanceof ShutdownHookSingleProcessDestroyer) {
      ((ShutdownHookSingleProcessDestroyer)d).destroyProcess(true);
      log.info("Process destroyed");
    } else {
      throw new IllegalStateException(d + " is not a Runnable, cannot destroy process");
    }
  }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.serversetup

/** Stop the process that we started, if any, and wait for it to exit before returning */
  public void stop() {
    if(executor == null) {
      throw new IllegalStateException("Process not started, no Executor set");
    }
    final Object d = executor.getProcessDestroyer();
    if(d instanceof ShutdownHookSingleProcessDestroyer) {
      ((ShutdownHookSingleProcessDestroyer)d).destroyProcess(true);
      log.info("Process destroyed");
    } else {
      throw new IllegalStateException(d + " is not a Runnable, cannot destroy process");
    }
  }
}

相关文章