org.rhq.core.pluginapi.util
Class ProcessExecutionUtility

java.lang.Object
  extended by org.rhq.core.pluginapi.util.ProcessExecutionUtility

public class ProcessExecutionUtility
extends Object

A set of utility methods for creating ProcessExecutions.


Method Summary
static ProcessExecution createProcessExecution(File file)
          Creates a ProcessExecution for the specified file for the current platform.
static ProcessExecution createProcessExecution(String prefix, File file)
          Creates a ProcessExecution for the specified file for the current platform.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createProcessExecution

public static ProcessExecution createProcessExecution(File file)
Creates a ProcessExecution for the specified file for the current platform. If the current platform is Windows and the file name ends with ".bat" or ".cmd", the file will be assumed to be a Windows batch file, and the process execution will be initialized accordingly. Note, if the file is a UNIX script, its first line must be a valid #! reference to a script interpreter (e.g. #!/bin/sh), otherwise it will fail to execute. The returned ProcessExecution will have a non-null arguments list, an environment map that is a copy of the current process's environment, and a working directory set to its executable's parent directory.

Parameters:
file - an executable or a batch file
Returns:
a process execution

createProcessExecution

public static ProcessExecution createProcessExecution(String prefix,
                                                      File file)
Creates a ProcessExecution for the specified file for the current platform. If the current platform is Windows and the file name ends with ".bat" or ".cmd", the file will be assumed to be a Windows batch file, and the process execution will be initialized accordingly. Note, if the file is a UNIX script, its first line must be a valid #! reference to a script interpreter (e.g. #!/bin/sh), otherwise it will fail to execute. The returned ProcessExecution will have a non-null arguments list, an environment map that is a copy of the current process's environment, and a working directory set to its executable's parent directory.

Parameters:
prefix - a prefix command line that should be prepended to the executable's command line (e.g. "/usr/bin/nohup /usr/bin/sudo -u jboss -g jboss"). any files on the command line should be absolute paths. if null, no prefix command line will be prepended
file - an executable or a batch file
Returns:
a process execution


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.