|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Thread
edu.isi.pegasus.common.util.StreamGobbler
public class StreamGobbler
A Stream gobbler class to take care of reading from a stream and optionally write out to another stream. Allows for non blocking reads on both stdout and stderr, when invoking a process through Runtime.exec(). Also, the user can specify a callback that is called whenever anything is read from the stream.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
Thread.State, Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
private StreamGobblerCallback |
mCallback
The callback to be used. |
private InputStream |
mIPStream
The input stream that is to be read from. |
private LogManager |
mLogger
The handle to the logging object. |
private OutputStream |
mOPStream
The output stream to which the contents have to be redirected to. |
private String |
mPrompt
The prompt that is to be written to the output stream. |
private boolean |
mStarted
A boolean indicating whether the thread has started or not. |
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
StreamGobbler(InputStream is,
StreamGobblerCallback callback)
The overloaded constructor. |
|
| Method Summary | |
|---|---|
void |
close()
Closes the underneath input and output stream that were opened. |
protected void |
finalize()
Closes the open connections to the streams whenever this object is destroyed. |
void |
redirect(OutputStream ops,
String prompt)
Sets the output stream to which to redirect the contents of the input stream. |
void |
run()
The main method of the gobbler, that does all the work. |
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private InputStream mIPStream
private OutputStream mOPStream
private StreamGobblerCallback mCallback
private String mPrompt
private boolean mStarted
private LogManager mLogger
| Constructor Detail |
|---|
public StreamGobbler(InputStream is,
StreamGobblerCallback callback)
is - the input stream from which to read from.callback - the callback to call when a line is read.| Method Detail |
|---|
public void redirect(OutputStream ops,
String prompt)
ops - the output stream.prompt - the prompt for the output stream.public void run()
run in interface Runnablerun in class Threadprotected void finalize()
finalize in class Objectpublic void close()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||