Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| WebLogic Integration
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bea.adapter.util
Class CommandRunner

    java.lang.Object
      |
      +--java.lang.Thread
            |
            +--com.bea.adapter.util.CommandRunner

public class CommandRunner
extends java.lang.Thread

Helper class for executing a command via a Process obtained by the Runtime object in a thread. The main value-add of this class is to allow for setting a maximum time to wait for the process to return and if the max is exceeded, handle the error reporting gracefully. Here's how to use the CommandRunner to compile a Java file using "javac":

     CommandRunner runner = new CommandRunner("javac HelloWorld.java");
     runner.start();
     if (!CommandRunner.SUCCESS.equals(runner.getExitValue())) {
       throw new IllegalStateException(runner.getErrorMessage());
     }

Author:
  Copyright © 2000, 2001 BEA Systems, Inc. All Rights Reserved.

Field Summary
`static long` | `DEFAULT_MAX_WAIT` The default max wait period for waiting for a process to complete.
`static java.lang.String` | `EXCEPTION` Possible return value from `getExitValue`; indicates that an exception was encountered while executing the command, such as the executable was not in the user's path.
`static java.lang.String` | `SUCCESS` Possible return value from `getExitValue`; indicates that the external process returned 0 as an exit value.
`static java.lang.String` | `TIMEOUT` Possible return value from `getExitValue`; indicates the process did NOT return an exit value in the maximum allowable time period, perhaps the external process is hung.

Fields inherited from class java.lang.Thread
`MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

Constructor Summary
`CommandRunner(java.lang.String strCommand)` Constructs an instance to execute a command and wait a maximum of 10 seconds for it to finish.
`CommandRunner(java.lang.String strCommand, long lMaxWait)` Constructs an instance to execute a command and wait a maximum of `lMaxWait` milliseconds for it to finish.

Method Summary
`java.lang.String` | `getCommand()`
`java.lang.String` | `getErrorMessage()`
`java.lang.String` | `getExitValue()` Returns the exit value from executing the command: CommandRunner.TIMEOUT indicates that the process timed-out, CommandRunner.SUCCESS indicates the process returned 0, CommandRunner.EXCEPTION indicates an exception was encountered while executing the command.
`void` | `run()` Executes the command established in the constructor.

Methods inherited from class java.lang.Thread
`activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield`

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

Field Detail

### EXCEPTION

    public static final java.lang.String EXCEPTION

  Possible return value from `getExitValue`; indicates that an exception was encountered while executing the command, such as the executable was not in the user's path.

### TIMEOUT

    public static final java.lang.String TIMEOUT

  Possible return value from `getExitValue`; indicates the process did NOT return an exit value in the maximum allowable time period, perhaps the external process is hung.

### SUCCESS

    public static final java.lang.String SUCCESS

  Possible return value from `getExitValue`; indicates that the external process returned 0 as an exit value.

### DEFAULT_MAX_WAIT

    public static final long DEFAULT_MAX_WAIT

  The default max wait period for waiting for a process to complete.

Constructor Detail

### CommandRunner

    public CommandRunner(java.lang.String strCommand)

  Constructs an instance to execute a command and wait a maximum of 10 seconds for it to finish.

  Parameters:
    `strCommand` - - command to execute

### CommandRunner

    public CommandRunner(java.lang.String strCommand,
                         long lMaxWait)

  Constructs an instance to execute a command and wait a maximum of `lMaxWait` milliseconds for it to finish.

  Parameters:
    `strCommand` - - command to execute
    `lMaxWait` - - maximum number of milliseconds to wait until the command returns a value.

Method Detail

### getExitValue

    public java.lang.String getExitValue()

  Returns the exit value from executing the command: CommandRunner.TIMEOUT indicates that the process timed-out, CommandRunner.SUCCESS indicates the process returned 0, CommandRunner.EXCEPTION indicates an exception was encountered while executing the command.

  Returns:
    a String indicating the outcome of the command.

### getCommand

    public java.lang.String getCommand()

  Returns:
    the command that this instance executes.

### getErrorMessage

    public java.lang.String getErrorMessage()

  Returns:
    a String of information read from the process' error stream.

### run

    public void run()

  Executes the command established in the constructor.

  Overrides:
    run in class java.lang.Thread

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| WebLogic Integration
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

WebLogic Integration (WLI)