本文整理汇总了Java中org.apache.commons.exec.ShutdownHookProcessDestroyer类的典型用法代码示例。如果您正苦于以下问题:Java ShutdownHookProcessDestroyer类的具体用法?Java ShutdownHookProcessDestroyer怎么用?Java ShutdownHookProcessDestroyer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ShutdownHookProcessDestroyer类属于org.apache.commons.exec包,在下文中一共展示了ShutdownHookProcessDestroyer类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: call
import org.apache.commons.exec.ShutdownHookProcessDestroyer; //导入依赖的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: testKillEngineOnVmExit
import org.apache.commons.exec.ShutdownHookProcessDestroyer; //导入依赖的package包/类
@Test
public void testKillEngineOnVmExit() throws Exception
{
StartTestEngineMojo mojo = rule.getMojo();
Executor startedProcess = null;
try
{
startedProcess = mojo.startEngine();
assertThat(startedProcess.getProcessDestroyer()).isInstanceOf(ShutdownHookProcessDestroyer.class);
ShutdownHookProcessDestroyer jvmShutdownHoock = (ShutdownHookProcessDestroyer) startedProcess.getProcessDestroyer();
assertThat(jvmShutdownHoock.size())
.as("One started engine process must be killed on VM end.")
.isEqualTo(1);
}
finally
{
kill(startedProcess);
}
}
开发者ID:axonivy,项目名称:project-build-plugin,代码行数:20,代码来源:TestStartEngine.java
示例3: prepareDefaultExecutor
import org.apache.commons.exec.ShutdownHookProcessDestroyer; //导入依赖的package包/类
protected DefaultExecutor prepareDefaultExecutor(ExecCommand execCommand) {
DefaultExecutor executor = new ExecDefaultExecutor();
executor.setExitValues(null);
if (execCommand.getWorkingDir() != null) {
executor.setWorkingDirectory(new File(execCommand.getWorkingDir()).getAbsoluteFile());
}
if (execCommand.getTimeout() != ExecEndpoint.NO_TIMEOUT) {
executor.setWatchdog(new ExecuteWatchdog(execCommand.getTimeout()));
}
executor.setProcessDestroyer(new ShutdownHookProcessDestroyer());
return executor;
}
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:DefaultExecCommandExecutor.java
示例4: prepareDefaultExecutor
import org.apache.commons.exec.ShutdownHookProcessDestroyer; //导入依赖的package包/类
@Override
protected DefaultExecutor prepareDefaultExecutor(ExecCommand execCommand) {
DefaultExecutor executor = new DefaultExecutorMock();
executor.setExitValues(null);
executor.setProcessDestroyer(new ShutdownHookProcessDestroyer());
return executor;
}
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:ProvokeExceptionExecCommandExecutor.java
示例5: start
import org.apache.commons.exec.ShutdownHookProcessDestroyer; //导入依赖的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
示例6: createExecutor
import org.apache.commons.exec.ShutdownHookProcessDestroyer; //导入依赖的package包/类
private Executor createExecutor(File workingDirectory, long timeoutInSeconds) {
DefaultExecutor executor = new DefaultExecutor();
executor.setWorkingDirectory(workingDirectory);
executor.setProcessDestroyer(new ShutdownHookProcessDestroyer()); // Fixes #41
if (timeoutInSeconds > 0) {
executor.setWatchdog(new ExecuteWatchdog(timeoutInSeconds * 1000));
}
return executor;
}
开发者ID:eirslett,项目名称:frontend-maven-plugin,代码行数:12,代码来源:ProcessExecutor.java
示例7: run
import org.apache.commons.exec.ShutdownHookProcessDestroyer; //导入依赖的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.ShutdownHookProcessDestroyer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论