|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.mmbase.util.externalprocess.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 java.io.OutputStream |
error
The stream where data is written to when piped from stderr |
protected org.mmbase.util.externalprocess.StreamCopyThread |
errorReader
Thread for copying bytes from stderr to error |
protected java.io.InputStream |
input
The stream where data is read from to pipe it to stdin |
protected org.mmbase.util.externalprocess.StreamCopyThread |
inputWriter
Thread for copying bytes from input to stdin |
protected java.lang.String |
name
the name of the process closure |
protected java.io.OutputStream |
output
The stream where data is written to when piped from stdout |
protected org.mmbase.util.externalprocess.StreamCopyThread |
outputReader
Thread for copying bytes from stdout to output |
protected java.lang.Process |
process
the process object representing the external process |
| Constructor Summary | |
ProcessClosure(java.lang.String name,
java.lang.Process process,
java.io.InputStream inputStream,
java.io.OutputStream outputStream,
java.io.OutputStream errorStream)
Creates a process reader . |
|
| Method Summary | |
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 java.lang.String name
protected java.lang.Process process
protected java.io.InputStream input
protected java.io.OutputStream output
protected java.io.OutputStream error
protected org.mmbase.util.externalprocess.StreamCopyThread inputWriter
protected org.mmbase.util.externalprocess.StreamCopyThread outputReader
protected org.mmbase.util.externalprocess.StreamCopyThread errorReader
| Constructor Detail |
public ProcessClosure(java.lang.String name,
java.lang.Process process,
java.io.InputStream inputStream,
java.io.OutputStream outputStream,
java.io.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 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 | ||||||||