Top Description Inners Fields Constructors Methods
org.apache.tools.ant.taskdefs

public Class PumpStreamHandler

extends Object
implements ExecuteStreamHandler
Class Inheritance
All Implemented Interfaces
org.apache.tools.ant.taskdefs.ExecuteStreamHandler
Known Direct Subclasses
org.apache.tools.ant.taskdefs.cvslib.RedirectingStreamHandler, org.apache.tools.ant.taskdefs.LogStreamHandler
Imports
java.io.IOException, .InputStream, .OutputStream, java.util.concurrent.TimeUnit, org.apache.tools.ant.util.FileUtils

Copies standard output and error of subprocesses to standard output and error of the parent process.
Since
Ant 1.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
PumpStreamHandler.ThreadWithPumper

Specialized subclass that allows access to the running StreamPumper.

Field Summary

Modifier and TypeField and Description
private OutputStream
private Thread
private InputStream
private Thread
private static final long
private final boolean
private OutputStream
private Thread

Constructor Summary

AccessConstructor and Description
public
PumpStreamHandler(OutputStream
the output OutputStream, must not be null.
out
,
OutputStream
the error OutputStream, must not be null.
err
,
InputStream
the input InputStream.
input
,
boolean
set it to true if the input should be read with simulated non blocking IO.
nonBlockingRead
)

Construct a new PumpStreamHandler.

public
PumpStreamHandler(OutputStream
the output OutputStream, must not be null.
out
,
OutputStream
the error OutputStream, must not be null.
err
,
InputStream
the input InputStream.
input
)

Construct a new PumpStreamHandler.

public
PumpStreamHandler(OutputStream
the output OutputStream, must not be null.
out
,
OutputStream
the error OutputStream, must not be null.
err
)

Construct a new PumpStreamHandler.

public
PumpStreamHandler(OutputStream
the output/error OutputStream, must not be null.
outAndErr
)

Construct a new PumpStreamHandler.

public
PumpStreamHandler()

Construct a new PumpStreamHandler.

Method Summary

Modifier and TypeMethod and Description
protected void
createProcessErrorPump(InputStream
the input stream to copy from.
is
,
OutputStream
the output stream to copy to.
os
)

Create the pump to handle error output.

protected void
createProcessOutputPump(InputStream
the InputStream.
is
,
OutputStream
the OutputStream.
os
)

Create the pump to handle process output.

protected Thread

Returns:

a thread object that does the pumping.
createPump
(InputStream
the input stream to copy from.
is
,
OutputStream
the output stream to copy to.
os
)

Creates a stream pumper to copy the given input stream to the given output stream.

protected Thread

Returns:

a thread object that does the pumping, subclasses should return an instance of ThreadWithPumper.
createPump
(InputStream
the input stream to copy from.
is
,
OutputStream
the output stream to copy to.
os
,
boolean
if true close the inputstream.
closeWhenExhausted
)

Creates a stream pumper to copy the given input stream to the given output stream.

protected Thread

Returns:

a thread object that does the pumping, subclasses should return an instance of ThreadWithPumper.
createPump
(InputStream
the input stream to copy from.
is
,
OutputStream
the output stream to copy to.
os
,
boolean
if true close the inputstream.
closeWhenExhausted
,
boolean
set it to true to use simulated non blocking IO.
nonBlockingIO
)

Creates a stream pumper to copy the given input stream to the given output stream.

protected final void
finish(Thread
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 OutputStream

Returns:

OutputStream.
getErr
()

Get the error stream.

protected OutputStream

Returns:

OutputStream.
getOut
()

Get the output stream.

public void
setProcessErrorStream(InputStream
the InputStream.
is
)

Implements org.apache.tools.ant.taskdefs.ExecuteStreamHandler.setProcessErrorStream.

Set the InputStream from which to read the standard error of the process.
public void
setProcessInputStream(OutputStream
the OutputStream.
os
)

Implements org.apache.tools.ant.taskdefs.ExecuteStreamHandler.setProcessInputStream.

Set the OutputStream by means of which input can be sent to the process.
public void
setProcessOutputStream(InputStream
the InputStream.
is
)

Implements org.apache.tools.ant.taskdefs.ExecuteStreamHandler.setProcessOutputStream.

Set the InputStream from which to read the standard output of the process.
public void
private void
public void
stop()

Implements org.apache.tools.ant.taskdefs.ExecuteStreamHandler.stop.

Stop pumping the streams.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

errback to summary
private OutputStream err
errorThreadback to summary
private Thread errorThread
inputback to summary
private InputStream input
inputThreadback to summary
private Thread inputThread
JOIN_TIMEOUTback to summary
private static final long JOIN_TIMEOUT
nonBlockingReadback to summary
private final boolean nonBlockingRead
outback to summary
private OutputStream out
outputThreadback to summary
private Thread outputThread

Constructor Detail

PumpStreamHandlerback to summary
public PumpStreamHandler(OutputStream out, OutputStream err, InputStream input, boolean nonBlockingRead)

Construct a new PumpStreamHandler.

Parameters
out:OutputStream

the output OutputStream, must not be null.

err:OutputStream

the error OutputStream, must not be null.

input:InputStream

the input InputStream.

nonBlockingRead:boolean

set it to true if the input should be read with simulated non blocking IO.

PumpStreamHandlerback to summary
public PumpStreamHandler(OutputStream out, OutputStream err, InputStream input)

Construct a new PumpStreamHandler.

Parameters
out:OutputStream

the output OutputStream, must not be null.

err:OutputStream

the error OutputStream, must not be null.

input:InputStream

the input InputStream.

PumpStreamHandlerback to summary
public PumpStreamHandler(OutputStream out, OutputStream err)

Construct a new PumpStreamHandler.

Parameters
out:OutputStream

the output OutputStream, must not be null.

err:OutputStream

the error OutputStream, must not be null.

PumpStreamHandlerback to summary
public PumpStreamHandler(OutputStream outAndErr)

Construct a new PumpStreamHandler.

Parameters
outAndErr:OutputStream

the output/error OutputStream, must not be null.

PumpStreamHandlerback to summary
public PumpStreamHandler()

Construct a new PumpStreamHandler.

Method Detail

createProcessErrorPumpback to summary
protected void createProcessErrorPump(InputStream is, OutputStream os)

Create the pump to handle error output.

Parameters
is:InputStream

the input stream to copy from.

os:OutputStream

the output stream to copy to.

createProcessOutputPumpback to summary
protected void createProcessOutputPump(InputStream is, OutputStream os)

Create the pump to handle process output.

Parameters
is:InputStream

the InputStream.

os:OutputStream

the OutputStream.

createPumpback to summary
protected Thread createPump(InputStream is, OutputStream os)

Creates a stream pumper to copy the given input stream to the given output stream.

Parameters
is:InputStream

the input stream to copy from.

os:OutputStream

the output stream to copy to.

Returns:Thread

a thread object that does the pumping.

createPumpback to summary
protected Thread createPump(InputStream is, OutputStream os, boolean closeWhenExhausted)

Creates a stream pumper to copy the given input stream to the given output stream.

Parameters
is:InputStream

the input stream to copy from.

os:OutputStream

the output stream to copy to.

closeWhenExhausted:boolean

if true close the inputstream.

Returns:Thread

a thread object that does the pumping, subclasses should return an instance of ThreadWithPumper.

createPumpback to summary
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:InputStream

the input stream to copy from.

os:OutputStream

the output stream to copy to.

closeWhenExhausted:boolean

if true close the inputstream.

nonBlockingIO:boolean

set it to true to use simulated non blocking IO.

Returns:Thread

a thread object that does the pumping, subclasses should return an instance of ThreadWithPumper.

Since
Ant 1.8.2
finishback to summary
protected final void finish(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.

Parameters
t:Thread

Thread

Since
Ant 1.8.0
getErrback to summary
protected OutputStream getErr()

Get the error stream.

Returns:OutputStream

OutputStream.

getOutback to summary
protected OutputStream getOut()

Get the output stream.

Returns:OutputStream

OutputStream.

setProcessErrorStreamback to summary
public void setProcessErrorStream(InputStream is)

Implements org.apache.tools.ant.taskdefs.ExecuteStreamHandler.setProcessErrorStream.

Set the InputStream from which to read the standard error of the process.

Parameters
is:InputStream

the InputStream.

setProcessInputStreamback to summary
public void setProcessInputStream(OutputStream os)

Implements org.apache.tools.ant.taskdefs.ExecuteStreamHandler.setProcessInputStream.

Set the OutputStream by means of which input can be sent to the process.

Parameters
os:OutputStream

the OutputStream.

setProcessOutputStreamback to summary
public void setProcessOutputStream(InputStream is)

Implements org.apache.tools.ant.taskdefs.ExecuteStreamHandler.setProcessOutputStream.

Set the InputStream from which to read the standard output of the process.

Parameters
is:InputStream

the InputStream.

startback to summary
public void start()

Implements org.apache.tools.ant.taskdefs.ExecuteStreamHandler.start.

Start the Threads.

startback to summary
private void start(Thread t)
stopback to summary
public void stop()

Implements org.apache.tools.ant.taskdefs.ExecuteStreamHandler.stop.

Stop pumping the streams.

org.apache.tools.ant.taskdefs back to summary

protected Class PumpStreamHandler.ThreadWithPumper

extends Thread
Class Inheritance

Specialized subclass that allows access to the running StreamPumper.
Since
Ant 1.8.0

Field Summary

Modifier and TypeField and Description
private final StreamPumper
Inherited from java.lang.Thread:
MAX_PRIORITYMIN_PRIORITYNORM_PRIORITY

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected StreamPumper
Inherited from java.lang.Thread:
activeCountcheckAccessclonecurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitresumerunsetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadstopsuspendthreadIdtoStringyield

Field Detail

pumperback to summary
private final StreamPumper pumper

Constructor Detail

ThreadWithPumperback to summary
public ThreadWithPumper(StreamPumper p)

Method Detail

getPumperback to summary
protected StreamPumper getPumper()