Package org.apache.karaf.util.process
Class PumpStreamHandler
- java.lang.Object
-
- org.apache.karaf.util.process.PumpStreamHandler
-
public class PumpStreamHandler extends Object
Copies standard output and error of children streams to standard output and error of the parent.
-
-
Constructor Summary
Constructors Constructor Description PumpStreamHandler(InputStream in, OutputStream out, OutputStream err)PumpStreamHandler(InputStream in, OutputStream out, OutputStream err, String name)PumpStreamHandler(OutputStream outAndErr)PumpStreamHandler(OutputStream out, OutputStream err)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattach(Process p)Attach to a child streams from the given process.protected voidcreateChildErrorPump(InputStream in, OutputStream out)Create the pump to handle error output.protected voidcreateChildOutputPump(InputStream in, OutputStream out)Create the pump to handle child output.protected StreamPumpercreateInputPump(InputStream in, OutputStream out, boolean closeWhenExhausted)Create a stream pumper to copy the given input stream to the given output stream.protected StreamPumpercreatePump(InputStream in, OutputStream out)Create a stream pumper to copy the given input stream to the given output stream.protected StreamPumpercreatePump(InputStream in, OutputStream out, boolean closeWhenExhausted)Create a stream pumper to copy the given input stream to the given output stream.StreamPumpergetErrorPump()StreamPumpergetOutputPump()voidsetChildErrorStream(InputStream in)Set the input stream from which to read the standard error of the child.voidsetChildInputStream(OutputStream out)Set the output stream by means of which input can be sent to the child.voidsetChildOutputStream(InputStream in)Set the input stream from which to read the standard output of the child.voidstart()Start pumping the streams.voidstop()Stop pumping the streams.
-
-
-
Constructor Detail
-
PumpStreamHandler
public PumpStreamHandler(InputStream in, OutputStream out, OutputStream err, String name)
-
PumpStreamHandler
public PumpStreamHandler(InputStream in, OutputStream out, OutputStream err)
-
PumpStreamHandler
public PumpStreamHandler(OutputStream out, OutputStream err)
-
PumpStreamHandler
public PumpStreamHandler(OutputStream outAndErr)
-
-
Method Detail
-
setChildOutputStream
public void setChildOutputStream(InputStream in)
Set the input stream from which to read the standard output of the child.- Parameters:
in- the the child output stream.
-
setChildErrorStream
public void setChildErrorStream(InputStream in)
Set the input stream from which to read the standard error of the child.- Parameters:
in- set the child error stream.
-
setChildInputStream
public void setChildInputStream(OutputStream out)
Set the output stream by means of which input can be sent to the child.- Parameters:
out- set the child output stream.
-
attach
public void attach(Process p)
Attach to a child streams from the given process.- Parameters:
p- The process to attach to.
-
start
public void start()
Start pumping the streams.
-
stop
public void stop()
Stop pumping the streams.
-
createChildOutputPump
protected void createChildOutputPump(InputStream in, OutputStream out)
Create the pump to handle child output.- Parameters:
in- the child input stream.out- the child output stream.
-
createChildErrorPump
protected void createChildErrorPump(InputStream in, OutputStream out)
Create the pump to handle error output.- Parameters:
in- the child input stream.out- the child output stream.
-
createPump
protected StreamPumper createPump(InputStream in, OutputStream out)
Create a stream pumper to copy the given input stream to the given output stream.- Parameters:
in- the child input stream.out- the child output stream.- Returns:
- A thread object that does the pumping.
-
createPump
protected StreamPumper createPump(InputStream in, OutputStream out, boolean closeWhenExhausted)
Create a stream pumper to copy the given input stream to the given output stream.- Parameters:
in- The input stream to copy from.out- The output stream to copy to.closeWhenExhausted- If true close the input stream.- Returns:
- A thread object that does the pumping.
-
createInputPump
protected StreamPumper createInputPump(InputStream in, OutputStream out, boolean closeWhenExhausted)
Create a stream pumper to copy the given input stream to the given output stream. Used for standard input.- Parameters:
in- The input stream to copy from.out- The output stream to copy to.closeWhenExhausted- If true close the input stream.- Returns:
- A thread object that does the pumping.
-
getOutputPump
public StreamPumper getOutputPump()
-
getErrorPump
public StreamPumper getErrorPump()
-
-