public class PumpStreamHandler extends java.lang.Object implements ExecuteStreamHandler
| Modifier and Type | Class and Description |
|---|---|
protected static class |
PumpStreamHandler.ThreadWithPumper
Specialized subclass that allows access to the running StreamPumper.
|
| Constructor and Description |
|---|
PumpStreamHandler()
Construct a new
PumpStreamHandler. |
PumpStreamHandler(java.io.OutputStream outAndErr)
Construct a new
PumpStreamHandler. |
PumpStreamHandler(java.io.OutputStream out,
java.io.OutputStream err)
Construct a new
PumpStreamHandler. |
PumpStreamHandler(java.io.OutputStream out,
java.io.OutputStream err,
java.io.InputStream input)
Construct a new
PumpStreamHandler. |
PumpStreamHandler(java.io.OutputStream out,
java.io.OutputStream err,
java.io.InputStream input,
boolean nonBlockingRead)
Construct a new
PumpStreamHandler. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
createProcessErrorPump(java.io.InputStream is,
java.io.OutputStream os)
Create the pump to handle error output.
|
protected void |
createProcessOutputPump(java.io.InputStream is,
java.io.OutputStream os)
Create the pump to handle process output.
|
protected java.lang.Thread |
createPump(java.io.InputStream is,
java.io.OutputStream os)
Creates a stream pumper to copy the given input stream to the
given output stream.
|
protected java.lang.Thread |
createPump(java.io.InputStream is,
java.io.OutputStream os,
boolean closeWhenExhausted)
Creates a stream pumper to copy the given input stream to the
given output stream.
|
protected java.lang.Thread |
createPump(java.io.InputStream is,
java.io.OutputStream os,
boolean closeWhenExhausted,
boolean nonBlockingIO)
Creates a stream pumper to copy the given input stream to the
given output stream.
|
protected void |
finish(java.lang.Thread t)
Waits for a thread to finish while trying to make it finish
quicker by stopping the pumper (if the thread is a
ThreadWithPumper instance) or interrupting
the thread. |
protected java.io.OutputStream |
getErr()
Get the error stream.
|
protected java.io.OutputStream |
getOut()
Get the output stream.
|
void |
setProcessErrorStream(java.io.InputStream is)
Set the
InputStream from which to read the
standard error of the process. |
void |
setProcessInputStream(java.io.OutputStream os)
Set the
OutputStream by means of which
input can be sent to the process. |
void |
setProcessOutputStream(java.io.InputStream is)
Set the
InputStream from which to read the
standard output of the process. |
void |
start()
Start the
Threads. |
void |
stop()
Stop pumping the streams.
|
public PumpStreamHandler(java.io.OutputStream out,
java.io.OutputStream err,
java.io.InputStream input,
boolean nonBlockingRead)
PumpStreamHandler.out - the output OutputStream, must not be null.err - the error OutputStream, must not be null.input - the input InputStream.nonBlockingRead - set it to true if the input should be
read with simulated non blocking IO.public PumpStreamHandler(java.io.OutputStream out,
java.io.OutputStream err,
java.io.InputStream input)
PumpStreamHandler.out - the output OutputStream, must not be null.err - the error OutputStream, must not be null.input - the input InputStream.public PumpStreamHandler(java.io.OutputStream out,
java.io.OutputStream err)
PumpStreamHandler.out - the output OutputStream, must not be null.err - the error OutputStream, must not be null.public PumpStreamHandler(java.io.OutputStream outAndErr)
PumpStreamHandler.outAndErr - the output/error OutputStream, must not be null.public PumpStreamHandler()
PumpStreamHandler.public void setProcessOutputStream(java.io.InputStream is)
InputStream from which to read the
standard output of the process.setProcessOutputStream in interface ExecuteStreamHandleris - the InputStream.public void setProcessErrorStream(java.io.InputStream is)
InputStream from which to read the
standard error of the process.setProcessErrorStream in interface ExecuteStreamHandleris - the InputStream.public void setProcessInputStream(java.io.OutputStream os)
OutputStream by means of which
input can be sent to the process.setProcessInputStream in interface ExecuteStreamHandleros - the OutputStream.public void start()
Threads.start in interface ExecuteStreamHandlerpublic void stop()
stop in interface ExecuteStreamHandlerprotected final void finish(java.lang.Thread t)
ThreadWithPumper instance) or interrupting
the thread.t - Threadprotected java.io.OutputStream getErr()
OutputStream.protected java.io.OutputStream getOut()
OutputStream.protected void createProcessOutputPump(java.io.InputStream is,
java.io.OutputStream os)
is - the InputStream.os - the OutputStream.protected void createProcessErrorPump(java.io.InputStream is,
java.io.OutputStream os)
is - the input stream to copy from.os - the output stream to copy to.protected java.lang.Thread createPump(java.io.InputStream is,
java.io.OutputStream os)
is - the input stream to copy from.os - the output stream to copy to.protected java.lang.Thread createPump(java.io.InputStream is,
java.io.OutputStream os,
boolean closeWhenExhausted)
is - the input stream to copy from.os - the output stream to copy to.closeWhenExhausted - if true close the inputstream.ThreadWithPumper.protected java.lang.Thread createPump(java.io.InputStream is,
java.io.OutputStream os,
boolean closeWhenExhausted,
boolean nonBlockingIO)
is - the input stream to copy from.os - the output stream to copy to.closeWhenExhausted - if true close the inputstream.nonBlockingIO - set it to true to use simulated non
blocking IO.ThreadWithPumper.