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
 
 public class PumpStreamHandler extends java.lang.Object implements ExecuteStreamHandler Copies standard output and error of subprocesses to standard output and error of the parent process.- Since:
- Ant 1.2
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected static classPumpStreamHandler.ThreadWithPumperSpecialized subclass that allows access to the running StreamPumper.
 - 
Constructor SummaryConstructors Constructor Description PumpStreamHandler()Construct a newPumpStreamHandler.PumpStreamHandler(java.io.OutputStream outAndErr)Construct a newPumpStreamHandler.PumpStreamHandler(java.io.OutputStream out, java.io.OutputStream err)Construct a newPumpStreamHandler.PumpStreamHandler(java.io.OutputStream out, java.io.OutputStream err, java.io.InputStream input)Construct a newPumpStreamHandler.PumpStreamHandler(java.io.OutputStream out, java.io.OutputStream err, java.io.InputStream input, boolean nonBlockingRead)Construct a newPumpStreamHandler.
 - 
Method SummaryModifier and Type Method Description protected voidcreateProcessErrorPump(java.io.InputStream is, java.io.OutputStream os)Create the pump to handle error output.protected voidcreateProcessOutputPump(java.io.InputStream is, java.io.OutputStream os)Create the pump to handle process output.protected java.lang.ThreadcreatePump(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.ThreadcreatePump(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.ThreadcreatePump(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 voidfinish(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 aThreadWithPumperinstance) or interrupting the thread.protected java.io.OutputStreamgetErr()Get the error stream.protected java.io.OutputStreamgetOut()Get the output stream.voidsetProcessErrorStream(java.io.InputStream is)Set theInputStreamfrom which to read the standard error of the process.voidsetProcessInputStream(java.io.OutputStream os)Set theOutputStreamby means of which input can be sent to the process.voidsetProcessOutputStream(java.io.InputStream is)Set theInputStreamfrom which to read the standard output of the process.voidstart()Start theThreads.voidstop()Stop pumping the streams.
 
- 
- 
- 
Constructor Detail- 
PumpStreamHandlerpublic PumpStreamHandler(java.io.OutputStream out, java.io.OutputStream err, java.io.InputStream input, boolean nonBlockingRead)Construct a newPumpStreamHandler.- Parameters:
- out- the output- OutputStream, must not be null.
- err- the error- OutputStream, must not be null.
- input- the input- InputStream.
- nonBlockingRead- set it to- trueif the input should be read with simulated non blocking IO.
 
 - 
PumpStreamHandlerpublic PumpStreamHandler(java.io.OutputStream out, java.io.OutputStream err, java.io.InputStream input)Construct a newPumpStreamHandler.- Parameters:
- out- the output- OutputStream, must not be null.
- err- the error- OutputStream, must not be null.
- input- the input- InputStream.
 
 - 
PumpStreamHandlerpublic PumpStreamHandler(java.io.OutputStream out, java.io.OutputStream err)Construct a newPumpStreamHandler.- Parameters:
- out- the output- OutputStream, must not be null.
- err- the error- OutputStream, must not be null.
 
 - 
PumpStreamHandlerpublic PumpStreamHandler(java.io.OutputStream outAndErr) Construct a newPumpStreamHandler.- Parameters:
- outAndErr- the output/error- OutputStream, must not be null.
 
 - 
PumpStreamHandlerpublic PumpStreamHandler() Construct a newPumpStreamHandler.
 
- 
 - 
Method Detail- 
setProcessOutputStreampublic void setProcessOutputStream(java.io.InputStream is) Set theInputStreamfrom which to read the standard output of the process.- Specified by:
- setProcessOutputStreamin interface- ExecuteStreamHandler
- Parameters:
- is- the- InputStream.
 
 - 
setProcessErrorStreampublic void setProcessErrorStream(java.io.InputStream is) Set theInputStreamfrom which to read the standard error of the process.- Specified by:
- setProcessErrorStreamin interface- ExecuteStreamHandler
- Parameters:
- is- the- InputStream.
 
 - 
setProcessInputStreampublic void setProcessInputStream(java.io.OutputStream os) Set theOutputStreamby means of which input can be sent to the process.- Specified by:
- setProcessInputStreamin interface- ExecuteStreamHandler
- Parameters:
- os- the- OutputStream.
 
 - 
startpublic void start() Start theThreads.- Specified by:
- startin interface- ExecuteStreamHandler
 
 - 
stoppublic void stop() Stop pumping the streams.- Specified by:
- stopin interface- ExecuteStreamHandler
 
 - 
finishprotected final 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 aThreadWithPumperinstance) or interrupting the thread.- Parameters:
- t- Thread
- Since:
- Ant 1.8.0
 
 - 
getErrprotected java.io.OutputStream getErr() Get the error stream.- Returns:
- OutputStream.
 
 - 
getOutprotected java.io.OutputStream getOut() Get the output stream.- Returns:
- OutputStream.
 
 - 
createProcessOutputPumpprotected void createProcessOutputPump(java.io.InputStream is, java.io.OutputStream os)Create the pump to handle process output.- Parameters:
- is- the- InputStream.
- os- the- OutputStream.
 
 - 
createProcessErrorPumpprotected void createProcessErrorPump(java.io.InputStream is, java.io.OutputStream os)Create the pump to handle error output.- Parameters:
- is- the input stream to copy from.
- os- the output stream to copy to.
 
 - 
createPumpprotected 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.- Parameters:
- is- the input stream to copy from.
- os- the output stream to copy to.
- Returns:
- a thread object that does the pumping.
 
 - 
createPumpprotected 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.- 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.
 
 - 
createPumpprotected 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.- Parameters:
- is- the input stream to copy from.
- os- the output stream to copy to.
- closeWhenExhausted- if true close the inputstream.
- nonBlockingIO- set it to- trueto 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
 
 
- 
 
-