juju.reattore.util
Class Spawner

java.lang.Object
  |
  +--juju.reattore.util.Spawner
All Implemented Interfaces:
java.lang.Runnable

public class Spawner
extends java.lang.Object
implements java.lang.Runnable

A native process wrapper that provides higher level functionality over Runtime.exec()


Constructor Summary
Spawner()
           
 
Method Summary
 void destroy()
          Kills the process if it is not yet finished.
 int exitValue()
          The exit code of the process, if present.
 java.util.List getOutput()
          The processes stdout and stderr, combined, as a list of strings.
 boolean isDone()
          Set if the process is finished.
 void run()
          Internal method.
 void setCommand(java.lang.String command)
          The Runtime.exec command to run.
 void setDir(java.lang.String dir)
          The working directory to start in.
 void spawn()
          Starts the process running in the background and waits for it to start.
 void waitDone()
          Waits for the process to terminate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Spawner

public Spawner()
Method Detail

run

public void run()
Internal method.

Specified by:
run in interface java.lang.Runnable

setCommand

public void setCommand(java.lang.String command)
The Runtime.exec command to run.

Parameters:
command - The command.

setDir

public void setDir(java.lang.String dir)
The working directory to start in. null means unset.

Parameters:
dir - Working directory.

spawn

public void spawn()
           throws java.lang.Exception
Starts the process running in the background and waits for it to start.

Throws:
java.lang.Exception - on error.

waitDone

public void waitDone()
              throws java.lang.Exception
Waits for the process to terminate.

Throws:
java.lang.Exception - on error.

exitValue

public int exitValue()
The exit code of the process, if present. Not valid until the process completes.

Returns:
The exit value.

isDone

public boolean isDone()
Set if the process is finished.

Returns:
true if finished.

destroy

public void destroy()
             throws java.lang.Exception
Kills the process if it is not yet finished.

Throws:
java.lang.Exception - on error.

getOutput

public java.util.List getOutput()
The processes stdout and stderr, combined, as a list of strings. The controller calls notifyAll() when lines are added.

Returns:
The processes output.


Copyright © 2002-2003 Michael Hope. All Rights Reserved.