|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mmbase.util.externalprocess.ProcessClosure
public class ProcessClosure
ProcessClosure handles the reading of the stdout and stderr of a external process. A reader can block the calling thread until it is finished reading (readBlocking). Or the reader can immidiately return when reading of the stdout and stderr begins (readNonBlocking). ProcessClosure handles the writing of the stdin of a external process. A writer can block the calling thread until it is finished writing to the stdin and reading the stdout and stderr (writeBlocking). Or the writer can imidiately return when writing to stdin and reading of the stdout and sterr begins (writeNonBlocking)
| Field Summary | |
|---|---|
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 Summary | |
|---|---|
ProcessClosure(String name,
Process process,
InputStream inputStream,
OutputStream outputStream,
OutputStream errorStream)
Creates a process reader . |
|
| Method Summary | |
|---|---|
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 |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
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
| Constructor Detail |
|---|
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 output| Method Detail |
|---|
public 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()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||