com.Prominic.runtime
Class DefaultNProcess

java.lang.Object
  extended by java.lang.Thread
      extended by com.Prominic.runtime.DefaultNProcess
All Implemented Interfaces:
NProcess, java.lang.Runnable

public class DefaultNProcess
extends java.lang.Thread
implements NProcess

java.lang.Process wrapper Creation date: (8/14/2001 10:45:55 AM)


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  java.util.Vector listeners
           
private  java.lang.Process process
           
private  boolean running
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
DefaultNProcess()
          Create a new DefaultNProcess object.
DefaultNProcess(java.lang.Process process)
          Create a new DefaultJProcess wrapper object around the specified process.
 
Method Summary
 void addProcessEventListener(ProcessEventListener listener)
          Add a new ProcessEventListener to this process.
 void destroy()
          Kill the spawned process.
protected  void dispatch(ProcessEvent event)
          Dispatch the specified process event to all listeners.
 int exitValue()
          Return the process exit value.
 java.io.InputStream getErrorStream()
          Return a stream to the stderr of the spawned process.
 java.io.InputStream getInputStream()
          Return a reference to the stdout of the spawned process.
protected  java.util.Vector getListeners()
          Return the list of listeners of this process.
 java.io.OutputStream getOutputStream()
          Return a reference to process' stdin stream.
 int getPid()
          Return the pid of the spawned process.
protected  java.lang.Process getProcess()
          Returns the reference to the process object.
 boolean isRunning()
          Returns true if this thread is still doing something.
 void removeProcessEventListener(ProcessEventListener listener)
          Removes the specified ProcessEventListener from the listeners list associated to this process.
 void run()
          Waits for the process to finish.
protected  void setListeners(java.util.Vector newListeners)
          Set the vector of ProcessEventListeners.
protected  void setProcess(java.lang.Process newProcess)
          Creation date: (8/14/2001 10:48:29 AM)
 void signal(int signal)
          Send a signal to the spawned process.
 void waitFor()
          Wait for the spawned process to finish.
 void waitFor(long time)
          Wait for this process to finish executing.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

process

private java.lang.Process process

listeners

private java.util.Vector listeners

running

private boolean running
Constructor Detail

DefaultNProcess

public DefaultNProcess()
Create a new DefaultNProcess object.


DefaultNProcess

public DefaultNProcess(java.lang.Process process)
Create a new DefaultJProcess wrapper object around the specified process.

Parameters:
process - java.lang.Process;
Method Detail

addProcessEventListener

public void addProcessEventListener(ProcessEventListener listener)
                             throws java.lang.IllegalThreadStateException
Add a new ProcessEventListener to this process. Creation date: (8/14/2001 10:45:55 AM)

Specified by:
addProcessEventListener in interface NProcess
Parameters:
listener - com.Prominic.jdi.spawning.ProcessEventListener
Throws:
java.lang.IllegalThreadStateException

destroy

public void destroy()
Kill the spawned process. Creation date: (8/17/2001 4:54:03 PM)

Specified by:
destroy in interface NProcess
Overrides:
destroy in class java.lang.Thread

dispatch

protected void dispatch(ProcessEvent event)
Dispatch the specified process event to all listeners. Creation date: (8/14/2001 10:51:14 AM)

Parameters:
event - com.Prominic.jdi.spawning.ProcessEvent

exitValue

public int exitValue()
              throws java.lang.IllegalThreadStateException
Return the process exit value. Creation date: (8/14/2001 10:45:55 AM)

Specified by:
exitValue in interface NProcess
Returns:
int
Throws:
java.io.IOException.
java.lang.IllegalThreadStateException

getErrorStream

public java.io.InputStream getErrorStream()
                                   throws java.io.IOException
Return a stream to the stderr of the spawned process. Creation date: (8/14/2001 10:45:55 AM)

Specified by:
getErrorStream in interface NProcess
Returns:
java.io.InputStream
Throws:
java.io.IOException.
java.io.IOException - The exception description.

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Return a reference to the stdout of the spawned process. Creation date: (8/14/2001 10:45:55 AM)

Specified by:
getInputStream in interface NProcess
Returns:
java.io.InputStream
Throws:
java.io.IOException

getListeners

protected java.util.Vector getListeners()
Return the list of listeners of this process. Creation date: (8/14/2001 10:49:55 AM)

Returns:
java.util.Vector

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Return a reference to process' stdin stream. Creation date: (8/14/2001 10:45:55 AM)

Specified by:
getOutputStream in interface NProcess
Returns:
java.io.OutputStream
Throws:
java.io.IOException

getPid

public int getPid()
           throws java.lang.IllegalThreadStateException
Return the pid of the spawned process. Creation date: (8/17/2001 4:57:55 PM)

Specified by:
getPid in interface NProcess
Returns:
int
Throws:
java.lang.IllegalThreadStateException - If the process is still running.

getProcess

protected java.lang.Process getProcess()
Returns the reference to the process object. Creation date: (8/14/2001 10:48:29 AM)

Returns:
java.lang.Process

isRunning

public boolean isRunning()
Returns true if this thread is still doing something. Creation date: (8/14/2001 2:51:54 PM)

Specified by:
isRunning in interface NProcess
Returns:
boolean

removeProcessEventListener

public void removeProcessEventListener(ProcessEventListener listener)
Removes the specified ProcessEventListener from the listeners list associated to this process. Creation date: (8/14/2001 10:45:55 AM)

Specified by:
removeProcessEventListener in interface NProcess
Parameters:
listener - com.Prominic.jdi.spawning.ProcessEventListener

run

public void run()
Waits for the process to finish. Creation date: (8/14/2001 10:57:43 AM)

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

setListeners

protected void setListeners(java.util.Vector newListeners)
Set the vector of ProcessEventListeners. Creation date: (8/14/2001 10:49:55 AM)

Parameters:
newListeners - java.util.Vector

setProcess

protected void setProcess(java.lang.Process newProcess)
Creation date: (8/14/2001 10:48:29 AM)

Parameters:
newProcess - java.lang.Process

signal

public void signal(int signal)
            throws java.io.IOException
Send a signal to the spawned process. Creation date: (8/14/2001 10:45:55 AM)

Specified by:
signal in interface NProcess
Parameters:
signal - int
Throws:
java.io.IOException

waitFor

public void waitFor()
             throws java.lang.InterruptedException
Wait for the spawned process to finish. Creation date: (8/15/2001 11:40:46 AM)

Specified by:
waitFor in interface NProcess
Throws:
java.lang.InterruptedException - If the thread is interrupted.

waitFor

public void waitFor(long time)
             throws java.lang.InterruptedException
Wait for this process to finish executing. If the specified time (milliseconds) expires, this method returns anyway. Creation date: (8/15/2001 11:40:46 AM)

Specified by:
waitFor in interface NProcess
Parameters:
time - int
Throws:
java.lang.InterruptedException - If the thread is interrupted.