org.rhq.core.system
Class ProcessExecution

java.lang.Object
  extended by org.rhq.core.system.ProcessExecution

public class ProcessExecution
extends Object

Provides information on what process to execute and how to execute it.


Constructor Summary
ProcessExecution(String executable)
          Constructor for ProcessExecution that defines the full path to the executable that will be run.
 
Method Summary
 List<String> getArguments()
           
 String[] getArgumentsAsArray()
           
 Map<String,String> getEnvironmentVariables()
           
 String[] getEnvironmentVariablesAsArray()
          Returns a copy of this ProcessExecution's environment variables as an array of "name=value" Strings.
 String getExecutable()
           
 long getWaitForCompletion()
           
 String getWorkingDirectory()
           
 boolean isCaptureOutput()
           
 boolean isKillOnTimeout()
           
 void setArguments(List<String> arguments)
          Sets an optional set of arguments to pass to the executable.
 void setArguments(String[] arguments)
          Sets an optional set of arguments to pass to the executable.
 void setCaptureOutput(boolean captureOutput)
          If true, the process's output will be captured and returned in the results.
 void setEnvironmentVariables(Map<String,String> environmentVariables)
          Sets an optional set of environment variables to pass to the process.
 void setExecutable(String executable)
          Sets the full path to the executable that will be run.
 void setKillOnTimeout(boolean killOnTimeout)
          If true, then the process will be forcibly killed if it doesn't exit within the wait time.
 void setWaitForCompletion(long waitForCompletion)
          The time, in milliseconds, to wait for the process to exit (will not wait if 0 or less).
 void setWorkingDirectory(String workingDirectory)
          If not null, will be the working directory of the new process (if null, the new process's working directory will be the current working directory of caller).
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProcessExecution

public ProcessExecution(@NotNull
                        String executable)
Constructor for ProcessExecution that defines the full path to the executable that will be run. See the other setter methods in this class for the additional things you can set when executing a process.

Parameters:
executable - the full path to the executable that will be run
Method Detail

getExecutable

@NotNull
public String getExecutable()

setExecutable

public void setExecutable(@NotNull
                          String executable)
Sets the full path to the executable that will be run.

Parameters:
executable - the full path to the executable that will be run

getArguments

@Nullable
public List<String> getArguments()

getArgumentsAsArray

@Nullable
public String[] getArgumentsAsArray()

setArguments

public void setArguments(@Nullable
                         List<String> arguments)
Sets an optional set of arguments to pass to the executable.

Parameters:
arguments - an optional set of arguments to pass to the executable

setArguments

public void setArguments(@Nullable
                         String[] arguments)
Sets an optional set of arguments to pass to the executable.

Parameters:
arguments - an optional set of arguments to pass to the executable

getEnvironmentVariables

@Nullable
public Map<String,String> getEnvironmentVariables()

getEnvironmentVariablesAsArray

@Nullable
public String[] getEnvironmentVariablesAsArray()
Returns a copy of this ProcessExecution's environment variables as an array of "name=value" Strings. Note, since the array is only a copy of the environmentVariables property, modifications made to it will have no effect on this ProcessExecution.

Returns:
a copy of this ProcessExecution's environment variables as an array of "name=value" Strings

setEnvironmentVariables

public void setEnvironmentVariables(@Nullable
                                    Map<String,String> environmentVariables)
Sets an optional set of environment variables to pass to the process. If null, the new process will inherit the environment of the caller.

Parameters:
environmentVariables - an optional set of environment variables to pass to the process

getWorkingDirectory

@Nullable
public String getWorkingDirectory()

setWorkingDirectory

public void setWorkingDirectory(@Nullable
                                String workingDirectory)
If not null, will be the working directory of the new process (if null, the new process's working directory will be the current working directory of caller).

Parameters:
workingDirectory -

getWaitForCompletion

public long getWaitForCompletion()

setWaitForCompletion

public void setWaitForCompletion(long waitForCompletion)
The time, in milliseconds, to wait for the process to exit (will not wait if 0 or less).

Parameters:
waitForCompletion -

isCaptureOutput

public boolean isCaptureOutput()

setCaptureOutput

public void setCaptureOutput(boolean captureOutput)
If true, the process's output will be captured and returned in the results. This may be ignored if waitForCompletion is 0 or less. Be careful setting this to true, you must ensure that the process will not write a lot of output - you might run out of memory if the process is a long-lived daemon process that outputs a lot of log messages, for example. By default, output is *not* captured.

Parameters:
captureOutput - whether or not this process's output (stdout+stderr) should be captured and returned in the results

isKillOnTimeout

public boolean isKillOnTimeout()

setKillOnTimeout

public void setKillOnTimeout(boolean killOnTimeout)
If true, then the process will be forcibly killed if it doesn't exit within the wait time. If false, the process will be allowed to continue to run for as long as it needs - getWaitForCompletion() will only force the caller to "wake up" and not block waiting for the process to finish.

Parameters:
killOnTimeout -

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2008 RHQ Project Advisory Board (Red Hat, Inc. and Hyperic, Inc.). All Rights Reserved.