public interface ProcessInstance
| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
Kills the subprocess.
|
boolean |
destroy(long timeout,
TimeUnit unit)
Kills the subprocess.
|
ProcessConfiguration |
getConfiguration()
Returns the process configuration.
|
InputStream |
getError()
Returns the process error output.
|
String |
getErrorString()
Returns the process error output as a string.
|
int |
getExitCode()
Returns the exit value for the subprocess.
|
OutputStream |
getInput()
Returns the process standard input.
|
Process |
getInternalProcess()
Returns the underlying process.
|
InputStream |
getOutput()
Returns the process standard output.
|
byte[] |
getOutputBinary()
Returns the process standard output as bytes.
|
String |
getOutputString()
Returns the process standard output as a string.
|
Instant |
getStartTime()
Returns the process start time.
|
boolean |
isAlive()
Tests whether the subprocess is alive.
|
boolean |
isWaitSecondsTimedOut()
Returns
true if the process exited before the waiting time specified by ProcessConfiguration.getWaitSeconds()
elapsed. |
ProcessInstance |
run()
Runs a new process synchronously.
|
ProcessInstance |
runAsync()
Runs a new process asynchronously.
|
void |
setErrorString(String errorString)
Sets the process error output as a string.
|
void |
setOutputBinary(byte[] outputBinary)
Sets the process standard output as bytes.
|
void |
setOutputString(String outputString)
Sets the process standard output as a string.
|
void |
setStartTime(Instant startTime)
Sets the process start time.
|
void |
setWaitSecondsTimedOut(boolean waitSecondsTimedOut)
Sets the info that tells if the process exited before the waiting time specified by
ProcessConfiguration.getWaitSeconds() elapsed.
|
int |
waitFor()
Invokes
waitFor() in the underlying process. |
boolean |
waitFor(long timeout,
TimeUnit unit)
Invokes
waitFor(timeout, unit) in the underlying process. |
void |
waitForReady()
Waits until the process is ready.
|
Process getInternalProcess()
ProcessConfiguration getConfiguration()
String getOutputString()
void setOutputString(String outputString)
outputString - the process standard output as a string.byte[] getOutputBinary()
void setOutputBinary(byte[] outputBinary)
outputBinary - the process standard output as bytes.String getErrorString()
void setErrorString(String errorString)
errorString - the process error output as a string.Instant getStartTime()
void setStartTime(Instant startTime)
startTime - the process start time.boolean isWaitSecondsTimedOut()
true if the process exited before the waiting time specified by ProcessConfiguration.getWaitSeconds()
elapsed.void setWaitSecondsTimedOut(boolean waitSecondsTimedOut)
waitSecondsTimedOut - true if the timeout happened.OutputStream getInput()
InputStream getOutput()
InputStream getError()
ProcessInstance run() throws InterruptedException
If the input redirect type is STREAM you should invoke ProcessInstance.runAsync().
InterruptedException - on interrupted.ProcessInstance runAsync() throws InterruptedException
If the input redirect type is STREAM you should invoke manually
ProcessInstance.waitForReady() after writing to and closing
the subprocess standard input ProcessInstance.getInput().
InterruptedException - on interrupted.void waitForReady()
throws InterruptedException
InterruptedException - on interrupted.int waitFor()
throws InterruptedException
waitFor() in the underlying process. If not run previously, invokes waitForReady() first.InterruptedException - on interrupted.boolean waitFor(long timeout,
TimeUnit unit)
throws InterruptedException
waitFor(timeout, unit) in the underlying process. If not run previously, invokes waitForReady() first.timeout - the maximum time to wait.unit - the time unit of the timeout argument.true if the subprocess has exited and false if the waiting time elapsed before the subprocess has exited.InterruptedException - on interrupted.boolean isAlive()
true if the subprocess is alive.void destroy()
throws InterruptedException
InterruptedException - on interrupted.boolean destroy(long timeout,
TimeUnit unit)
throws InterruptedException
timeout - the maximum time to wait.unit - the time unit of the timeout argument.true if the subprocess has exited and false if the waiting time elapsed before the subprocess has exited.InterruptedException - on interrupted.int getExitCode()
Copyright © 2016–2020 Softelnet. All rights reserved.