org.objectweb.proactive.core.process
Class AbstractUniversalProcess

java.lang.Object
  |
  +--org.objectweb.proactive.core.process.AbstractUniversalProcess
All Implemented Interfaces:
java.io.Serializable, UniversalProcess
Direct Known Subclasses:
AbstractExternalProcess

public abstract class AbstractUniversalProcess
extends java.lang.Object
implements UniversalProcess

See Also:
Serialized Form

Field Summary
protected  java.lang.String certificateLocation
           
protected  java.lang.String command
           
static java.lang.String DEFAULT_HOSTNAME
           
static java.lang.String DEFAULT_USERNAME
           
protected  java.lang.String[] environment
           
protected  java.lang.String hostname
           
protected  boolean isFinished
           
protected  boolean isStarted
           
protected static java.lang.String LOCALHOST
           
protected  java.lang.String privateKeyLocation
           
protected  java.lang.String securityFile
           
protected  java.lang.String username
           
 
Fields inherited from interface org.objectweb.proactive.core.process.UniversalProcess
logger
 
Constructor Summary
protected AbstractUniversalProcess()
           
 
Method Summary
protected abstract  java.lang.String buildCommand()
           
protected  void checkStarted()
           
 java.lang.String getCertificateLocation()
           
 java.lang.String getCommand()
          Returns the command that will be or has been execute by the process.
 java.lang.String[] getEnvironment()
          Returns the current environment for this process.
 java.lang.String getHostname()
          Return the hostname target of this process.
 java.lang.String getPrivateKeyLocation()
           
 java.lang.String getSecurityFile()
           
 java.lang.String getUsername()
          Return the username that will be used to run the command.
protected abstract  void internalStartProcess(java.lang.String commandToExecute)
           
protected abstract  void internalStopProcess()
           
protected abstract  int internalWaitFor()
           
 boolean isFinished()
          Returns true if and only if this process has been stopped.
 boolean isStarted()
          Returns true if and only if this process has been started.
 void setCertificateLocation(java.lang.String file)
           
 void setEnvironment(java.lang.String[] environment)
          Set the environment for this process.
 void setHostname(java.lang.String hostname)
          Set the hostname target of this process.
 void setPrivateKeyLocation(java.lang.String privatekey)
           
 void setSecurityFile(java.lang.String securityFile)
           
 void setUsername(java.lang.String username)
          Set the username that will be used to run the command.
 void startProcess()
          Starts the process by executing the command.
 void stopProcess()
          Stops the running process.
 java.lang.String toString()
           
protected  void toString(java.lang.StringBuffer sb)
           
 int waitFor()
          Causes the current thread to wait until this Process has terminated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOCALHOST

protected static final java.lang.String LOCALHOST

DEFAULT_USERNAME

public static final java.lang.String DEFAULT_USERNAME

DEFAULT_HOSTNAME

public static final java.lang.String DEFAULT_HOSTNAME

hostname

protected java.lang.String hostname

username

protected java.lang.String username

environment

protected java.lang.String[] environment

command

protected java.lang.String command

isStarted

protected boolean isStarted

isFinished

protected boolean isFinished

certificateLocation

protected java.lang.String certificateLocation

privateKeyLocation

protected java.lang.String privateKeyLocation

securityFile

protected java.lang.String securityFile
Constructor Detail

AbstractUniversalProcess

protected AbstractUniversalProcess()
Method Detail

getCommand

public java.lang.String getCommand()
Description copied from interface: UniversalProcess
Returns the command that will be or has been execute by the process.

Specified by:
getCommand in interface UniversalProcess
Returns:
the command of this external process

setEnvironment

public void setEnvironment(java.lang.String[] environment)
Description copied from interface: UniversalProcess
Set the environment for this process. Each cell of the array contains the definition of one variable in a syntax that is system dependant.

Specified by:
setEnvironment in interface UniversalProcess

getEnvironment

public java.lang.String[] getEnvironment()
Description copied from interface: UniversalProcess
Returns the current environment for this process. Each cell of the array contains the definition of one variable in a syntax that is system dependant.

Specified by:
getEnvironment in interface UniversalProcess
Returns:
an array of string containing all environment variables or null if the environment is empty

getHostname

public java.lang.String getHostname()
Description copied from interface: UniversalProcess
Return the hostname target of this process.

Specified by:
getHostname in interface UniversalProcess
Returns:
the hostname target of this process.

setHostname

public void setHostname(java.lang.String hostname)
Description copied from interface: UniversalProcess
Set the hostname target of this process. By default the target host is the localhost.

Specified by:
setHostname in interface UniversalProcess

getUsername

public java.lang.String getUsername()
Description copied from interface: UniversalProcess
Return the username that will be used to run the command.

Specified by:
getUsername in interface UniversalProcess
Returns:
the username that will be used to run the command.

setUsername

public void setUsername(java.lang.String username)
Description copied from interface: UniversalProcess
Set the username that will be used to run the command. By default the current username owner of the JVM process is used.

Specified by:
setUsername in interface UniversalProcess

startProcess

public void startProcess()
                  throws java.io.IOException
Description copied from interface: UniversalProcess
Starts the process by executing the command. The process can only be started once.

Specified by:
startProcess in interface UniversalProcess
Throws:
java.io.IOException - if the process cannot be started.

stopProcess

public void stopProcess()
Description copied from interface: UniversalProcess
Stops the running process. If called on a stopped process this method has no effect.

Specified by:
stopProcess in interface UniversalProcess

waitFor

public int waitFor()
            throws java.lang.InterruptedException
Description copied from interface: UniversalProcess
Causes the current thread to wait until this Process has terminated. This method returns immediately if the subprocess has already terminated. If the subprocess has not yet terminated, the calling thread will be blocked until the subprocess exits.

Specified by:
waitFor in interface UniversalProcess
Returns:
int exit value
Throws:
java.lang.InterruptedException - if the current thread is interrupted by another thread while it is waiting. Then the wait is ended and an InterruptedException is thrown

isStarted

public boolean isStarted()
Description copied from interface: UniversalProcess
Returns true if and only if this process has been started. A process that has been started can be finished or running.

Specified by:
isStarted in interface UniversalProcess

isFinished

public boolean isFinished()
Description copied from interface: UniversalProcess
Returns true if and only if this process has been stopped. A process that has been stopped has been started and is no more running.

Specified by:
isFinished in interface UniversalProcess

toString

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

setCertificateLocation

public void setCertificateLocation(java.lang.String file)
Specified by:
setCertificateLocation in interface UniversalProcess

getCertificateLocation

public java.lang.String getCertificateLocation()
Specified by:
getCertificateLocation in interface UniversalProcess

setPrivateKeyLocation

public void setPrivateKeyLocation(java.lang.String privatekey)
Specified by:
setPrivateKeyLocation in interface UniversalProcess

getPrivateKeyLocation

public java.lang.String getPrivateKeyLocation()
Specified by:
getPrivateKeyLocation in interface UniversalProcess

setSecurityFile

public void setSecurityFile(java.lang.String securityFile)
Specified by:
setSecurityFile in interface UniversalProcess

getSecurityFile

public java.lang.String getSecurityFile()
Specified by:
getSecurityFile in interface UniversalProcess

toString

protected void toString(java.lang.StringBuffer sb)

checkStarted

protected void checkStarted()

buildCommand

protected abstract java.lang.String buildCommand()

internalStartProcess

protected abstract void internalStartProcess(java.lang.String commandToExecute)
                                      throws java.io.IOException
java.io.IOException

internalStopProcess

protected abstract void internalStopProcess()

internalWaitFor

protected abstract int internalWaitFor()
                                throws java.lang.InterruptedException
java.lang.InterruptedException


Copyright © April 2004 INRIA All Rights Reserved.