public class ProcessHandler extends java.lang.Thread implements DeferredProcessProxy
ProcessHandler
thread rather than using the main thread.Constructor and Description |
---|
ProcessHandler(byte[] input,
java.lang.Process process)
Create a
ProcessHandler with specified input
The input will be delivered to the process stdin (and the stream closed)
when the handler is run |
ProcessHandler(java.lang.Process process)
Create a
ProcessHandler
No input is provided for the process. |
Modifier and Type | Method and Description |
---|---|
void |
complete(long timeout_millis)
wait for the process to complete.
|
java.lang.Integer |
execute(long timeout_millis)
blocking call to the process.
|
java.lang.String |
getErr()
get the erro output of the process
|
java.lang.Integer |
getExit()
get the exit value of the process, This may return null if the timeout is reached.
|
java.io.IOException |
getInputException() |
java.lang.String |
getOutput()
get the output of the process
|
void |
run() |
void |
setTimeout(long timeout)
Set an automatic timeout for the
ProcessHandler implemented by a thread. |
void |
start()
Start the deferred process
|
boolean |
wasTerminated()
did the process time-out or killed via interrupt
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield
public ProcessHandler(java.lang.Process process)
ProcessHandler
No input is provided for the process. If any is required this must be
provided by a different thread.process
- public ProcessHandler(byte[] input, java.lang.Process process)
ProcessHandler
with specified input
The input will be delivered to the process stdin (and the stream closed)
when the handler is runinput
- process
- public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void setTimeout(long timeout)
ProcessHandler
implemented by a thread.
This can be used if the spawning thread is not going to wait for completion.setTimeout
in interface DeferredProcessProxy
timeout
- public java.lang.Integer getExit()
getExit
in interface ProcessProxy
public java.io.IOException getInputException()
public void start()
DeferredProcessProxy
start
in interface DeferredProcessProxy
start
in class java.lang.Thread
public java.lang.Integer execute(long timeout_millis) throws java.lang.Exception
execute
in interface DeferredProcessProxy
timeout_millis
- java.lang.Exception
public void complete(long timeout_millis) throws java.lang.InterruptedException
complete
in interface DeferredProcessProxy
timeout_millis
- java.lang.InterruptedException
public java.lang.String getOutput()
ProcessProxy
getOutput
in interface ProcessProxy
public java.lang.String getErr()
ProcessProxy
getErr
in interface ProcessProxy
public boolean wasTerminated()
ProcessProxy
wasTerminated
in interface ProcessProxy