Execute (Hyperic HQ Plugin API)
Keywords: org.hyperic.util.exec.Execute class

Overview | Package | Class | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 4.4.0.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.hyperic.util.exec
Class Execute

    java.lang.Object
      org.hyperic.util.exec.Execute

    public class Execute

extends java.lang.Object

Runs an external program.

Field Summary
`static int` | `INVALID` Invalid exit code.

Constructor Summary
`Execute()` Creates a new execute object using `PumpStreamHandler` for stream handling.
`Execute(ExecuteStreamHandler streamHandler)` Creates a new execute object.
`Execute(ExecuteStreamHandler streamHandler, ExecuteWatchdog watchdog)` Creates a new execute object.

Method Summary
`int` | `execute()` Runs a process defined by the command line and returns its exit status.
`static int` | `execute(java.util.Vector envVars, java.lang.String cmd, java.io.File baseDir)`
`static int` | `execute(java.util.Vector envVars, java.util.Vector cmd, java.io.File baseDir)`
`static int` | `execute(java.util.Vector envVars, java.util.Vector cmd, java.io.File baseDir, int timeToWait)` Wrapper for common execution patterns
`java.lang.String[]` | `getCommandline()` Returns the commandline used to create a subprocess.
`java.lang.String` | `getCommandLineString()`
`java.lang.String[]` | `getEnvironment()` Returns the environment used to create a subprocess.
`int` | `getExitValue()` query the exit value of the process.
`static java.util.Vector` | `getProcEnvironment()` Find the list of environment variables for this process.
`void` | `setCommandline(java.lang.String[] commandline)` Sets the commandline of the subprocess to launch.
`void` | `setEnvironment(java.lang.String[] env)` Sets the environment variables for the subprocess to launch.
`protected void` | `setExitValue(int value)`
`void` | `setNewenvironment(boolean newenv)` Set whether to propagate the default environment or not.
`void` | `setWait(boolean b)`
`void` | `setWorkingDirectory(java.io.File wd)` Sets the working directory of the process to execute.
`protected void` | `waitFor(java.lang.Process process)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### INVALID

    public static final int INVALID

  Invalid exit code.

  See Also:
    Constant Field Values

Constructor Detail

### Execute

    public Execute()

  Creates a new execute object using `PumpStreamHandler` for stream handling.

### Execute

    public Execute(ExecuteStreamHandler streamHandler)

  Creates a new execute object.

  Parameters:
    `streamHandler` - the stream handler used to handle the input and output streams of the subprocess.

### Execute

    public Execute(ExecuteStreamHandler streamHandler,
                   ExecuteWatchdog watchdog)

  Creates a new execute object.

  Parameters:
    `streamHandler` - the stream handler used to handle the input and output streams of the subprocess.
    `watchdog` - a watchdog for the subprocess or `null` to to disable a timeout for the subprocess.

Method Detail

### getProcEnvironment

    public static java.util.Vector getProcEnvironment()

  Find the list of environment variables for this process.

### getCommandline

    public java.lang.String[] getCommandline()

  Returns the commandline used to create a subprocess.

  Returns:
    the commandline used to create a subprocess

### getCommandLineString

    public java.lang.String getCommandLineString()

### setCommandline

    public void setCommandline(java.lang.String[] commandline)

  Sets the commandline of the subprocess to launch.

  Parameters:
    `commandline` - the commandline of the subprocess to launch

### setNewenvironment

    public void setNewenvironment(boolean newenv)

  Set whether to propagate the default environment or not.

  Parameters:
    `newenv` - whether to propagate the process environment.

### getEnvironment

    public java.lang.String[] getEnvironment()

  Returns the environment used to create a subprocess.

  Returns:
    the environment used to create a subprocess

### setEnvironment

    public void setEnvironment(java.lang.String[] env)

  Sets the environment variables for the subprocess to launch.

  Parameters:
    `commandline` - array of Strings, each element of which has an environment variable settings in format key=value

### setWorkingDirectory

    public void setWorkingDirectory(java.io.File wd)

  Sets the working directory of the process to execute.

  This is emulated using the antRun scripts unless the OS is Windows NT in which case a cmd.exe is spawned, or MRJ and setting user.dir works, or JDK 1.3 and there is official support in java.lang.Runtime.

  Parameters:
    `wd` - the working directory of the process.

### setWait

    public void setWait(boolean b)

### execute

    public int execute()
                throws java.lang.Exception

  Runs a process defined by the command line and returns its exit status.

  Returns:
    the exit status of the subprocess or `INVALID`
  Throws:
    `java.io.IOExcpetion` - The exception is thrown, if launching of the subprocess failed
    `java.lang.Exception`

### waitFor

    protected void waitFor(java.lang.Process process)

### setExitValue

    protected void setExitValue(int value)

### getExitValue

    public int getExitValue()

  query the exit value of the process.

  Returns:
    the exit value, 1 if the process was killed, or Project.INVALID if no exit value has been received

### execute

    public static int execute(java.util.Vector envVars,
                              java.lang.String cmd,
                              java.io.File baseDir)

### execute

    public static int execute(java.util.Vector envVars,
                              java.util.Vector cmd,
                              java.io.File baseDir)

### execute

    public static int execute(java.util.Vector envVars,
                              java.util.Vector cmd,
                              java.io.File baseDir,
                              int timeToWait)

  Wrapper for common execution patterns

  Parameters:
    `envVars` - Environment variables to execute with (optional)
    `cmd` - a vector of the commands to execute
    `baseDir` - the base directory to run from (optional)
    `timeToWait` - milliseconds to wait for completion

Overview | Package | Class | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 4.4.0.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004-2006 Hyperic, Inc. support@hyperic.net, All Rights Reserved.