本文整理汇总了Java中org.zeroturnaround.exec.stream.slf4j.Slf4jStream类的典型用法代码示例。如果您正苦于以下问题:Java Slf4jStream类的具体用法?Java Slf4jStream怎么用?Java Slf4jStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Slf4jStream类属于org.zeroturnaround.exec.stream.slf4j包,在下文中一共展示了Slf4jStream类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: execute
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
@Override
public void execute(final String[] arguments, final File directory) {
LOGGER.info(String.format("Execute maven at '%s': %s", directory, Arrays.toString(arguments)));
try {
final List<String> argumentsAsList = Lists.newArrayList(Arrays.asList(arguments));
argumentsAsList.add(0, getMavenCommand());
if (LOGGER.isDebugEnabled()) {
argumentsAsList.add("-e");
}
new ProcessExecutor() //
.command(argumentsAsList) //
.directory(directory) //
.redirectOutput(Slf4jStream.of(LOGGER).asDebug()) //
.redirectError(Slf4jStream.of(LOGGER).asError()) //
.execute();
} catch (final Exception exception) {
throw new MavenExecutionException(exception);
}
}
开发者ID:AGETO,项目名称:hybris-maven-plugin,代码行数:20,代码来源:ExternalInstalledMavenExecutor.java
示例2: taskkill
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
/**
* Sends the destroy signal to this process.
*
* @param forceful <code>true</code> if this process should be destroyed forcefully.
* @return <code>true</code> if this process got the signal, <code>false</code> if the process was not found (any more).
*
* @throws IOException on IO error.
* @throws InterruptedException if interrupted.
*/
public boolean taskkill(boolean forceful) throws IOException, InterruptedException {
try {
new ProcessExecutor()
.commandSplit(String.format("taskkill%s%s /PID %d", includeChildren ? " /T" : "", forceful ? " /F" : "", pid))
.redirectOutput(Slf4jStream.ofCaller().asDebug()).exitValueNormal().executeNoTimeout();
return true;
}
catch (InvalidExitValueException e) {
if (e.getExitValue() == EXIT_CODE_COULD_NOT_BE_TERMINATED) {
// Process could be either alive or not, if it's not alive we don't want to throw an exception
if (isAlive()) {
throw e; // process is still alive
}
return false; // process is stopped but but not because of us
}
if (e.getExitValue() == EXIT_CODE_NO_SUCH_PROCESS) {
return false;
}
throw e;
}
}
开发者ID:zeroturnaround,项目名称:zt-process-killer,代码行数:31,代码来源:WindowsProcess.java
示例3: isAlive
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
public boolean isAlive() throws IOException, InterruptedException {
try {
new ProcessExecutor()
.commandSplit(String.format("kill -0 %d", pid)).readOutput(true)
.redirectOutput(Slf4jStream.ofCaller().asTrace())
.setMessageLogger(MessageLoggers.TRACE)
.exitValueNormal()
.executeNoTimeout();
return true;
}
catch (InvalidExitValueException e) {
if (isNoSuchProcess(e)) {
return false;
}
throw e;
}
}
开发者ID:zeroturnaround,项目名称:zt-process-killer,代码行数:18,代码来源:UnixProcess.java
示例4: loadAgent
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
private static void loadAgent(final File tempAgentJar, final String pid) throws Exception {
if (DynamicInstrumentationReflections.isBeforeJava9()) {
DynamicInstrumentationLoadAgentMain.loadAgent(pid, tempAgentJar.getAbsolutePath());
} else {
//-Djdk.attach.allowAttachSelf https://www.bountysource.com/issues/45231289-self-attach-fails-on-jdk9
//workaround this limitation by attaching from a new process
final File loadAgentJar = createTempJar(DynamicInstrumentationLoadAgentMain.class, false);
final String javaExecutable = getJavaHome() + File.separator + "bin" + File.separator + "java";
final List<String> command = new ArrayList<String>();
command.add(javaExecutable);
command.add("-classpath");
command.add(loadAgentJar.getAbsolutePath()); //tools.jar not needed since java9
command.add(DynamicInstrumentationLoadAgentMain.class.getName());
command.add(pid);
command.add(tempAgentJar.getAbsolutePath());
new ProcessExecutor().command(command)
.destroyOnExit()
.exitValueNormal()
.redirectOutput(Slf4jStream.of(DynamicInstrumentationLoader.class).asInfo())
.redirectError(Slf4jStream.of(DynamicInstrumentationLoader.class).asWarn())
.execute();
}
}
开发者ID:subes,项目名称:invesdwin-instrument,代码行数:24,代码来源:DynamicInstrumentationLoader.java
示例5: frontendStart
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
private void frontendStart() throws IOException {
ProcessExecutor processExecutor = new ProcessExecutor()
.directory(new File("frontend"))
.command("yarn", "start")
.redirectOutput(Slf4jStream.of(LoggerFactory.getLogger("yarn")).asInfo())
.redirectError(Slf4jStream.of(LoggerFactory.getLogger("yarn")).asError());
if (isWindows()) {
processExecutor = processExecutor.command("cmd", "/c", "yarn", "start");
}
processExecutor.start();
}
开发者ID:UniteGG,项目名称:gamelocker-status,代码行数:14,代码来源:FrontendRunner.java
示例6: yarnStart
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
private void yarnStart(File frontendDir) throws IOException {
ProcessExecutor process = command("yarn", "start")
.directory(frontendDir)
.redirectOutput(Slf4jStream.of(LoggerFactory.getLogger("yarn")).asInfo())
.redirectError(Slf4jStream.of(LoggerFactory.getLogger("yarn")).asError());
process.start();
}
开发者ID:wlindner,项目名称:ReBoot,代码行数:9,代码来源:YarnRunner.java
示例7: yarnInstall
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
private void yarnInstall(File frontendDir) throws InterruptedException, TimeoutException, IOException {
command("yarn", "install")
.directory(frontendDir)
.redirectOutput(Slf4jStream.of(LoggerFactory.getLogger("yarn")).asInfo())
.redirectError(Slf4jStream.of(LoggerFactory.getLogger("yarn")).asError())
.exitValueNormal()
.execute();
}
开发者ID:wlindner,项目名称:ReBoot,代码行数:9,代码来源:YarnRunner.java
示例8: getErlangVersion
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
/**
* @return a String representing the Erlang version, such as {@code "18.2.1"}
* @throws ErlangShellException if the Erlang command can't be executed or if it exits unexpectedly.
*/
public String getErlangVersion() throws ErlangShellException {
String erlangShell = UNIX_ERL_COMMAND;
Logger processOutputLogger = LoggerFactory.getLogger(
String.format(LOGGER_TEMPLATE, this.getClass().getName(), erlangShell));
Slf4jStream stream = Slf4jStream.of(processOutputLogger);
final ProcessExecutor processExecutor = config.getProcessExecutorFactory().createInstance()
.command(erlangShell, "-noshell", "-eval", "erlang:display(erlang:system_info(otp_release)), halt().")
.timeout(config.getErlangCheckTimeoutInMillis(), TimeUnit.MILLISECONDS)
.redirectError(stream.as(Level.WARN))
.destroyOnExit()
.readOutput(true);
try {
ProcessResult processResult = processExecutor.execute();
int exitValue = processResult.getExitValue();
if (exitValue == 0) {
return processResult.outputUTF8().trim().replaceAll("[\"\\\\n]", ""); // "18.2.1\n" -> "18.2.1"
} else {
throw new ErlangShellException("Erlang exited with status " + exitValue);
}
} catch (IOException | InterruptedException | TimeoutException e) {
throw new ErlangShellException("Exception executing Erlang shell command", e);
}
}
开发者ID:AlejandroRivera,项目名称:embedded-rabbitmq,代码行数:32,代码来源:ErlangShell.java
示例9: call
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
@Override
public StartedProcess call() throws RabbitMqCommandException {
List<String> fullCommand = new ArrayList<>(arguments);
fullCommand.add(0, executableFile.toString());
Slf4jStream loggingStream = Slf4jStream.of(processOutputLogger);
LoggingProcessListener loggingListener = new LoggingProcessListener(processOutputLogger);
ProcessExecutor processExecutor = processExecutorFactory.createInstance()
.environment(config.getEnvVars())
.directory(config.getAppFolder())
.command(fullCommand)
.destroyOnExit()
.addListener(loggingListener) // Logs process events (like start, stop...)
.addListener(eventsListener) // Notifies asynchronously of process events (start/finish/stop)
.redirectError(loggingStream.as(stdErrLogLevel)) // Logging for output made to STDERR
.redirectOutput(loggingStream.as(stdOutLogLevel)) // Logging for output made to STDOUT
.redirectOutputAlsoTo(outputStream) // Pipe stdout to this stream for the application to process
.redirectErrorAlsoTo(errorOutputStream) // Pipe stderr to this stream for the application to process
.readOutput(storeOutput); // Store the output in the ProcessResult as well.
try {
return processExecutor.start();
} catch (IOException e) {
throw new RabbitMqCommandException("Failed to execute: " + StringUtils.join(fullCommand, " "), e);
}
}
开发者ID:AlejandroRivera,项目名称:embedded-rabbitmq,代码行数:29,代码来源:RabbitMqCommand.java
示例10: execCommand
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
private static void execCommand(final String... command) throws Exception {
new ProcessExecutor().command(command)
.destroyOnExit()
.timeout(1, TimeUnit.MINUTES)
.exitValueNormal()
.redirectOutput(Slf4jStream.of(SynchronousChannels.class).asInfo())
.redirectError(Slf4jStream.of(SynchronousChannels.class).asWarn())
.stopper(new ProcessStopper() {
@Override
public void stop(final Process process) {
process.destroy();
}
})
.execute();
}
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:16,代码来源:SynchronousChannels.java
示例11: isAlive
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
public boolean isAlive() throws IOException, InterruptedException {
String out = new ProcessExecutor()
.commandSplit(String.format("%s process where ProcessId=%d get ProcessId", wmicPath, pid))
.readOutput(true)
.redirectOutput(Slf4jStream.ofCaller().asTrace())
.setMessageLogger(MessageLoggers.TRACE)
.exitValueNormal()
.executeNoTimeout().outputString();
return out.contains(String.valueOf(pid));
}
开发者ID:zeroturnaround,项目名称:zt-process-killer,代码行数:11,代码来源:WindowsProcess.java
示例12: kill
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
/**
* Sends a signal to this process.
*
* @param signal name of the signal.
* @return <code>true</code> if this process received the signal, <code>false</code> if this process was not found (any more).
*
* @throws IOException on IO error.
* @throws InterruptedException if interrupted.
*/
public boolean kill(String signal) throws IOException, InterruptedException {
try {
new ProcessExecutor()
.commandSplit(String.format("kill -%s %d", signal, pid))
.redirectOutput(Slf4jStream.ofCaller().asDebug()).exitValueNormal().executeNoTimeout();
return true;
}
catch (InvalidExitValueException e) {
if (isNoSuchProcess(e)) {
return false;
}
throw e;
}
}
开发者ID:zeroturnaround,项目名称:zt-process-killer,代码行数:24,代码来源:UnixProcess.java
示例13: executeCommand
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
public String executeCommand(String... args) {
try {
log.debug("Executing command " + Arrays.asList(args));
return executor().command(args)
.timeout(60, TimeUnit.SECONDS)
.redirectError(Slf4jStream.of(getClass()).asInfo())
.readOutput(true).execute()
.outputUTF8();
} catch (Exception e) {
log.warn("Exception while calling command " + Arrays.asList(args) + ": " + e);
throw new ExternalProcessException(e);
}
}
开发者ID:TouK,项目名称:sputnik,代码行数:14,代码来源:ExternalProcess.java
示例14: runAssertionCheckScript
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
private int runAssertionCheckScript() throws Exception {
assertTrue(wordAssertScript.exists());
return new ProcessExecutor()
.command(Arrays.asList("cmd", "/C", String.format("\"%s\"", wordAssertScript.getAbsolutePath())))
.redirectOutput(Slf4jStream.of(LOGGER).asInfo())
.redirectError(Slf4jStream.of(LOGGER).asInfo())
.timeout(1L, TimeUnit.MINUTES)
.exitValueAny()
.execute()
.getExitValue();
}
开发者ID:documents4j,项目名称:documents4j,代码行数:12,代码来源:MicrosoftOfficeAssertionEngine.java
示例15: kill
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
public void kill() throws Exception {
assertTrue(wordShutdownScript.exists());
new ProcessExecutor()
.command(Arrays.asList("cmd", "/C", String.format("\"%s\"", wordShutdownScript.getAbsolutePath())))
.redirectOutput(Slf4jStream.of(LOGGER).asInfo())
.redirectError(Slf4jStream.of(LOGGER).asInfo())
.timeout(1L, TimeUnit.MINUTES)
.exitValueAny()
.execute()
.getExitValue();
}
开发者ID:documents4j,项目名称:documents4j,代码行数:12,代码来源:MicrosoftOfficeAssertionEngine.java
示例16: makePresetProcessExecutor
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
protected ProcessExecutor makePresetProcessExecutor() {
return new ProcessExecutor()
.redirectOutput(Slf4jStream.of(logger).asInfo())
.redirectError(Slf4jStream.of(logger).asInfo())
.readOutput(true)
.directory(getBaseFolder())
.timeout(getProcessTimeout(), TimeUnit.MILLISECONDS)
.exitValueAny();
}
开发者ID:documents4j,项目名称:documents4j,代码行数:10,代码来源:AbstractExternalConverter.java
示例17: pumpErrorToLoggerAndGetOutput
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
String pumpErrorToLoggerAndGetOutput() throws Exception {
String output = new ProcessExecutor().command("java", "-version")
.redirectError(Slf4jStream.of(getClass()).asInfo())
.readOutput(true).execute()
.outputUTF8();
return output;
}
开发者ID:zeroturnaround,项目名称:zt-exec,代码行数:8,代码来源:ReadmeExamples.java
示例18: testSlf4jLoggerName
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
private void testSlf4jLoggerName(String fullName, Slf4jStream stream) {
ProcessExecutor executor = new ProcessExecutor();
executor.redirectOutput(stream.asInfo());
PumpStreamHandler pumps = executor.pumps();
OutputStream out = pumps.getOut();
Assert.assertTrue("Slf4jInfoOutputStream expected", out instanceof Slf4jInfoOutputStream);
Assert.assertEquals(fullName, ((Slf4jInfoOutputStream) out).getLogger().getName());
}
开发者ID:zeroturnaround,项目名称:zt-exec,代码行数:9,代码来源:ProcessExecutorLoggerTest.java
示例19: testJavaVersionLogInfoAndOutput
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
@Test
public void testJavaVersionLogInfoAndOutput() throws Exception {
// Just expect no errors - don't check the log file itself
ProcessResult result = new ProcessExecutor().command("java", "-version").redirectOutput(Slf4jStream.of("testJavaVersionLogInfoAndOutput").asInfo()).readOutput(true).execute();
String str = result.outputUTF8();
Assert.assertFalse(StringUtils.isEmpty(str));
}
开发者ID:zeroturnaround,项目名称:zt-exec,代码行数:8,代码来源:ProcessExecutorMainTest.java
示例20: testJavaVersionLogInfoAndOutputFuture
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream; //导入依赖的package包/类
@Test
public void testJavaVersionLogInfoAndOutputFuture() throws Exception {
// Just expect no errors - don't check the log file itself
ProcessResult result = new ProcessExecutor().command("java", "-version").redirectOutput(Slf4jStream.of("testJavaVersionLogInfoAndOutputFuture").asInfo()).readOutput(true).start().getFuture().get();
String str = result.outputUTF8();
Assert.assertFalse(StringUtils.isEmpty(str));
}
开发者ID:zeroturnaround,项目名称:zt-exec,代码行数:8,代码来源:ProcessExecutorMainTest.java
注:本文中的org.zeroturnaround.exec.stream.slf4j.Slf4jStream类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论