org.eodisp.util.launcher
Class ProcessImpl

java.lang.Object
  extended by org.eodisp.util.launcher.ProcessImpl
All Implemented Interfaces:
Process

public class ProcessImpl
extends java.lang.Object
implements Process

Version:
$Id:$
Author:
ibirrer

Field Summary
(package private) static org.apache.log4j.Logger logger
          Log4J logger for this class
 
Constructor Summary
ProcessImpl(org.apache.tools.ant.types.Commandline commandline)
           
ProcessImpl(org.apache.tools.ant.types.Commandline commandline, java.io.File workingDir)
           
ProcessImpl(org.apache.tools.ant.types.CommandlineJava commandlineJava)
           
ProcessImpl(org.apache.tools.ant.types.CommandlineJava commandlineJava, java.io.File workingdir)
           
 
Method Summary
 void addEnvVar(java.lang.String key, java.lang.String value)
          Adds the environment variable with the given key and value
 void addListener(ProcessListener processListener)
          Add a listener to this process to get notified of state changes.
 void addOutputStream(java.io.OutputStream stream)
           
 java.lang.String getClassname()
           
 boolean kill(long timeoutInMillis)
          Forcibly kills this process.
 void launch()
          Launches the process and returns immediately.
 int launchBlocking()
          Launches the process and block until the process terminates or the thread is being interrupted.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

static org.apache.log4j.Logger logger
Log4J logger for this class

Constructor Detail

ProcessImpl

public ProcessImpl(org.apache.tools.ant.types.CommandlineJava commandlineJava)

ProcessImpl

public ProcessImpl(org.apache.tools.ant.types.CommandlineJava commandlineJava,
                   java.io.File workingdir)

ProcessImpl

public ProcessImpl(org.apache.tools.ant.types.Commandline commandline)

ProcessImpl

public ProcessImpl(org.apache.tools.ant.types.Commandline commandline,
                   java.io.File workingDir)
Method Detail

addEnvVar

public void addEnvVar(java.lang.String key,
                      java.lang.String value)
Description copied from interface: Process
Adds the environment variable with the given key and value

Specified by:
addEnvVar in interface Process
Parameters:
key - the key of the environment variable
value - the value of the environment variable

kill

public boolean kill(long timeoutInMillis)
Forcibly kills this process. This method returns true if this process has been started and is not running anymore (for whatever reason). Returns false if Process.launch() has not been invoked. If this method returns true, it must return true for all subsequent calls to this method. If this method returns false it means that the process is probably still running.

Specified by:
kill in interface Process
Parameters:
timeoutInMillis - wait at most timeoutInMillis to try to kill the process. A value of 0 means to wait forever.
Returns:
true if the process has been stopped, false if the process is still running or has never been started.

launch

public void launch()
            throws java.io.IOException
Launches the process and returns immediately. Launches this process. A process cannot be launched twice. A second call to this method will always throw a IllegalStateException.

Specified by:
launch in interface Process
Throws:
java.io.IOException - thrown if this process could not be launched.

launchBlocking

public int launchBlocking()
                   throws java.io.IOException
Launches the process and block until the process terminates or the thread is being interrupted.

Specified by:
launchBlocking in interface Process
Throws:
java.io.IOException

addListener

public void addListener(ProcessListener processListener)
Add a listener to this process to get notified of state changes.

Specified by:
addListener in interface Process

getClassname

public java.lang.String getClassname()
Returns:
the class that is started by this process

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

addOutputStream

public void addOutputStream(java.io.OutputStream stream)
                     throws java.io.IOException
Throws:
java.io.IOException