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, yieldpublic 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.Runnablerun in class java.lang.Threadpublic 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 DeferredProcessProxytimeout - public java.lang.Integer getExit()
getExit in interface ProcessProxypublic java.io.IOException getInputException()
public void start()
DeferredProcessProxystart in interface DeferredProcessProxystart in class java.lang.Threadpublic java.lang.Integer execute(long timeout_millis)
throws java.lang.Exception
execute in interface DeferredProcessProxytimeout_millis - java.lang.Exceptionpublic void complete(long timeout_millis)
throws java.lang.InterruptedException
complete in interface DeferredProcessProxytimeout_millis - java.lang.InterruptedExceptionpublic java.lang.String getOutput()
ProcessProxygetOutput in interface ProcessProxypublic java.lang.String getErr()
ProcessProxygetErr in interface ProcessProxypublic boolean wasTerminated()
ProcessProxywasTerminated in interface ProcessProxy