Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.port80.eclipse.util
Class ProcessMonitor  view ProcessMonitor download ProcessMonitor.java

java.lang.Object
  extended bycom.port80.eclipse.util.ProcessMonitor

public class ProcessMonitor
extends java.lang.Object

Monitor a background process in a separate thread.


Field Summary
private static int BUFSIZE
           
protected  java.lang.StringBuffer errContent
           
protected  java.io.InputStream errStream
           
protected  java.lang.Thread errThread
          The output stream monitor thread.
protected  int exitValue
           
protected  IProcessMonitorListener listener
          Optional name for the monitor thread.
protected  java.lang.String name
          java.lang.Process being monitored.
protected  java.lang.StringBuffer outContent
           
protected  java.io.InputStream outStream
          The error stream monitor thread.
protected  java.lang.Thread outThread
          The process monitor thread.
protected  java.lang.Process process
           
protected  java.lang.Thread thread
           
 
Constructor Summary
ProcessMonitor(java.lang.Process process, java.lang.String name, IProcessMonitorListener listener)
           
ProcessMonitor(java.lang.Process process, java.lang.String name, IProcessMonitorListener listener, boolean monitor_output, boolean monitor_error)
          Creates a new process monitor and starts monitoring the process for termination.
 
Method Summary
(package private)  void errMonitor()
          Continually reads from the err stream of the process.
 int exitValue()
           
 java.lang.String getErrContent()
           
 java.lang.String getOutContent()
           
 void kill()
          Kills the monitoring thread.
static void main(java.lang.String[] args)
           
(package private)  void monitorProcess()
          Monitors the underlying process for termination.
(package private)  void outMonitor()
          Continually reads from the output stream of the process.
private  void startErrMonitor()
          Start the output stream monitoring thread.
private  void startOutMonitor()
          Start the output stream monitoring thread.
private  void startProcessMonitor()
          Starts monitoring the underlying process.
 void waitFor()
          Wait till the process being monitored is done.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFSIZE

private static final int BUFSIZE
See Also:
Constant Field Values

process

protected java.lang.Process process

name

protected java.lang.String name
java.lang.Process being monitored.


listener

protected IProcessMonitorListener listener
Optional name for the monitor thread.


thread

protected java.lang.Thread thread

outThread

protected java.lang.Thread outThread
The process monitor thread.


errThread

protected java.lang.Thread errThread
The output stream monitor thread.


outStream

protected java.io.InputStream outStream
The error stream monitor thread.


errStream

protected java.io.InputStream errStream

outContent

protected java.lang.StringBuffer outContent

errContent

protected java.lang.StringBuffer errContent

exitValue

protected int exitValue
Constructor Detail

ProcessMonitor

public ProcessMonitor(java.lang.Process process,
                      java.lang.String name,
                      IProcessMonitorListener listener,
                      boolean monitor_output,
                      boolean monitor_error)
Creates a new process monitor and starts monitoring the process for termination.


ProcessMonitor

public ProcessMonitor(java.lang.Process process,
                      java.lang.String name,
                      IProcessMonitorListener listener)
Method Detail

kill

public void kill()
Kills the monitoring thread. This method is to be useful for dealing with the error case of an underlying process to hang.


getOutContent

public java.lang.String getOutContent()

getErrContent

public java.lang.String getErrContent()

exitValue

public int exitValue()

waitFor

public void waitFor()
Wait till the process being monitored is done. If interrupted, the underlying process is killed.


startProcessMonitor

private void startProcessMonitor()
Starts monitoring the underlying process.


monitorProcess

void monitorProcess()
Monitors the underlying process for termination. When the underlying process terminates (or if the monitoring thread is interrupted), inform the IProcessMaster that it has terminated.


startOutMonitor

private void startOutMonitor()
Start the output stream monitoring thread.


outMonitor

void outMonitor()
Continually reads from the output stream of the process.


startErrMonitor

private void startErrMonitor()
Start the output stream monitoring thread.


errMonitor

void errMonitor()
Continually reads from the err stream of the process.


main

public static void main(java.lang.String[] args)