Package org.apache.tools.ant.taskdefs
Class PumpStreamHandler
java.lang.Object
org.apache.tools.ant.taskdefs.PumpStreamHandler
- All Implemented Interfaces:
ExecuteStreamHandler
- Direct Known Subclasses:
JUnitTask.JUnitLogStreamHandler
,LogStreamHandler
Copies standard output and error of subprocesses to standard output and
error of the parent process.
- Since:
- Ant 1.2
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Specialized subclass that allows access to the running StreamPumper. -
Constructor Summary
ConstructorDescriptionConstruct a newPumpStreamHandler
.PumpStreamHandler
(OutputStream outAndErr) Construct a newPumpStreamHandler
.PumpStreamHandler
(OutputStream out, OutputStream err) Construct a newPumpStreamHandler
.PumpStreamHandler
(OutputStream out, OutputStream err, InputStream input) Construct a newPumpStreamHandler
.PumpStreamHandler
(OutputStream out, OutputStream err, InputStream input, boolean nonBlockingRead) Construct a newPumpStreamHandler
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Create the pump to handle error output.protected void
Create the pump to handle process output.protected Thread
createPump
(InputStream is, OutputStream os) Creates a stream pumper to copy the given input stream to the given output stream.protected Thread
createPump
(InputStream is, OutputStream os, boolean closeWhenExhausted) Creates a stream pumper to copy the given input stream to the given output stream.protected Thread
createPump
(InputStream is, OutputStream os, boolean closeWhenExhausted, boolean nonBlockingIO) Creates a stream pumper to copy the given input stream to the given output stream.protected final void
Waits for a thread to finish while trying to make it finish quicker by stopping the pumper (if the thread is aThreadWithPumper
instance) or interrupting the thread.protected OutputStream
getErr()
Get the error stream.protected OutputStream
getOut()
Get the output stream.void
Set theInputStream
from which to read the standard error of the process.void
Set theOutputStream
by means of which input can be sent to the process.void
Set theInputStream
from which to read the standard output of the process.void
start()
Start theThread
s.void
stop()
Stop pumping the streams.
-
Constructor Details
-
PumpStreamHandler
public PumpStreamHandler(OutputStream out, OutputStream err, InputStream input, boolean nonBlockingRead) Construct a newPumpStreamHandler
.- Parameters:
out
- the outputOutputStream
, must not be null.err
- the errorOutputStream
, must not be null.input
- the inputInputStream
.nonBlockingRead
- set it totrue
if the input should be read with simulated non blocking IO.
-
PumpStreamHandler
Construct a newPumpStreamHandler
.- Parameters:
out
- the outputOutputStream
, must not be null.err
- the errorOutputStream
, must not be null.input
- the inputInputStream
.
-
PumpStreamHandler
Construct a newPumpStreamHandler
.- Parameters:
out
- the outputOutputStream
, must not be null.err
- the errorOutputStream
, must not be null.
-
PumpStreamHandler
Construct a newPumpStreamHandler
.- Parameters:
outAndErr
- the output/errorOutputStream
, must not be null.
-
PumpStreamHandler
public PumpStreamHandler()Construct a newPumpStreamHandler
.
-
-
Method Details
-
setProcessOutputStream
Set theInputStream
from which to read the standard output of the process.- Specified by:
setProcessOutputStream
in interfaceExecuteStreamHandler
- Parameters:
is
- theInputStream
.
-
setProcessErrorStream
Set theInputStream
from which to read the standard error of the process.- Specified by:
setProcessErrorStream
in interfaceExecuteStreamHandler
- Parameters:
is
- theInputStream
.
-
setProcessInputStream
Set theOutputStream
by means of which input can be sent to the process.- Specified by:
setProcessInputStream
in interfaceExecuteStreamHandler
- Parameters:
os
- theOutputStream
.
-
start
-
stop
-
finish
Waits for a thread to finish while trying to make it finish quicker by stopping the pumper (if the thread is aThreadWithPumper
instance) or interrupting the thread.- Parameters:
t
- Thread- Since:
- Ant 1.8.0
-
getErr
-
getOut
-
createProcessOutputPump
Create the pump to handle process output.- Parameters:
is
- theInputStream
.os
- theOutputStream
.
-
createProcessErrorPump
Create the pump to handle error output.- Parameters:
is
- the input stream to copy from.os
- the output stream to copy to.
-
createPump
Creates a stream pumper to copy the given input stream to the given output stream.- Parameters:
is
- the input stream to copy from.os
- the output stream to copy to.- Returns:
- a thread object that does the pumping.
-
createPump
Creates a stream pumper to copy the given input stream to the given output stream.- Parameters:
is
- the input stream to copy from.os
- the output stream to copy to.closeWhenExhausted
- if true close the inputstream.- Returns:
- a thread object that does the pumping, subclasses
should return an instance of
ThreadWithPumper
.
-
createPump
protected Thread createPump(InputStream is, OutputStream os, boolean closeWhenExhausted, boolean nonBlockingIO) Creates a stream pumper to copy the given input stream to the given output stream.- Parameters:
is
- the input stream to copy from.os
- the output stream to copy to.closeWhenExhausted
- if true close the inputstream.nonBlockingIO
- set it totrue
to use simulated non blocking IO.- Returns:
- a thread object that does the pumping, subclasses
should return an instance of
ThreadWithPumper
. - Since:
- Ant 1.8.2
-