rescuecore.tools.simulationrunner
Class RescueProcess

java.lang.Object
  extended byrescuecore.tools.simulationrunner.RescueProcess

public class RescueProcess
extends java.lang.Object


Constructor Summary
RescueProcess(java.lang.String name, java.lang.String commandline, java.lang.String started, java.lang.String logPrefix)
          Create a new RescueProcess
 
Method Summary
 void addErrorDestination(java.io.OutputStream stream)
          Add a new destination for the standard error stream from this process.
 void addOutputDestination(java.io.OutputStream stream)
          Add a new destination for the standard output stream from this process.
 java.lang.String getCommandLine()
          Get the command line used to start this process
 java.lang.String getName()
          Get the name of this process
 java.lang.String getStartedFlag()
          Get the string that delimits successful initialisation of this process
 boolean isRunning()
          Find out whether this process is running or not
 boolean start()
          Start this process and wait for the started flag to appear in the output.
 void stop()
          Stop the process
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RescueProcess

public RescueProcess(java.lang.String name,
                     java.lang.String commandline,
                     java.lang.String started,
                     java.lang.String logPrefix)
Create a new RescueProcess

Parameters:
name - The name of this process
commandline - The command line used to start the process
started - When this string is encountered in the standard output stream then this process is deemed to have initialised successfully. If this parameter is null, then the process is assumed to initialise instantaneously.
Method Detail

toString

public java.lang.String toString()

getName

public java.lang.String getName()
Get the name of this process

Returns:
The name of this process

getCommandLine

public java.lang.String getCommandLine()
Get the command line used to start this process

Returns:
The command line used to start this process

getStartedFlag

public java.lang.String getStartedFlag()
Get the string that delimits successful initialisation of this process

Returns:
The string that delimits successful initialisation

start

public boolean start()
Start this process and wait for the started flag to appear in the output. Standard output and standard error are automatically redirected to files called .log and .error, where is the value returned by the @{link #getName()} method.

Returns:
true iff the process starts successfully

addOutputDestination

public void addOutputDestination(java.io.OutputStream stream)
Add a new destination for the standard output stream from this process. Output data will be multiplexed to all destinations.

Parameters:
stream - An OutputStream to write standard output to

addErrorDestination

public void addErrorDestination(java.io.OutputStream stream)
Add a new destination for the standard error stream from this process. Output data will be multiplexed to all destinations.

Parameters:
stream - An OutputStream to write standard error to

isRunning

public boolean isRunning()
Find out whether this process is running or not

Returns:
true iff the process is running

stop

public void stop()
Stop the process