public class ProcessClosure extends Object
| Modifier and Type | Field and Description |
|---|---|
protected long |
count |
protected OutputStream |
error
The stream where data is written to when piped from stderr
|
protected StreamCopyThread |
errorReader
Thread for copying bytes from stderr to error
|
protected InputStream |
input
The stream where data is read from to pipe it to stdin
|
protected StreamCopyThread |
inputWriter
Thread for copying bytes from input to stdin
|
protected String |
name
the name of the process closure
|
protected OutputStream |
output
The stream where data is written to when piped from stdout
|
protected StreamCopyThread |
outputReader
Thread for copying bytes from stdout to output
|
protected Process |
process
the process object representing the external process
|
| Constructor and Description |
|---|
ProcessClosure(String name,
Process process,
InputStream inputStream,
OutputStream outputStream,
OutputStream errorStream)
Creates a process reader
.
|
| Modifier and Type | Method and Description |
|---|---|
long |
getCount() |
boolean |
isAlive()
Process closure is alive when the external process and writer/reader
threads are still busy
|
void |
readBlocking()
read data from the external process and block the calling thread until
reading is finished
|
void |
readNonBlocking()
read data from the external process without blocking the calling thread
|
void |
terminate()
Forces the termination of the launched process
|
protected void |
waitForProcess()
wait for the external process.to end
|
protected void |
waitForReaders()
wait for the reading threads to finish copying
|
protected void |
waitForWriter()
wait for the writing thread to finish copying
|
void |
writeBlocking()
write data to the external process and block the calling thread until
writing and reading is finished
|
void |
writeNonBlocking()
write data to the external process without blocking the calling thread
|
protected String name
protected Process process
protected InputStream input
protected OutputStream output
protected OutputStream error
protected StreamCopyThread inputWriter
protected StreamCopyThread outputReader
protected StreamCopyThread errorReader
protected long count
public ProcessClosure(String name, Process process, InputStream inputStream, OutputStream outputStream, OutputStream errorStream)
name - the name of the readerinputStream - process stdin is read from this stream. Can be
null, if not interested in writing the inputoutputStream - process stdout is written to this stream. Can be
null, if not interested in reading the outputerrorStream - porcess stderr is written to this stream. Can be
null, if not interested in reading the outputpublic void readNonBlocking()
public void writeNonBlocking()
public long getCount()
public void readBlocking()
public void writeBlocking()
protected void waitForProcess()
protected void waitForReaders()
protected void waitForWriter()
public boolean isAlive()
true if is alive and false otherwisepublic void terminate()
MMBase 1.9-SNAPSHOT - ${javadoctimestamp}