|
WebLogic Integration | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--com.bea.adapter.util.CommandRunner
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()); }
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 |
public static final java.lang.String EXCEPTION
getExitValue
; indicates that an
exception was encountered while executing the command, such as the
executable was not in the user's path.public static final java.lang.String TIMEOUT
getExitValue
; indicates the process
did NOT return an exit value in the maximum allowable time period, perhaps
the external process is hung.public static final java.lang.String SUCCESS
getExitValue
; indicates that the
external process returned 0 as an exit value.public static final long DEFAULT_MAX_WAIT
Constructor Detail |
public CommandRunner(java.lang.String strCommand)
strCommand
- - command to executepublic CommandRunner(java.lang.String strCommand, long lMaxWait)
lMaxWait
milliseconds for it to finish.
strCommand
- - command to executelMaxWait
- - maximum number of milliseconds to wait until the command
returns a value.Method Detail |
public java.lang.String getExitValue()
public java.lang.String getCommand()
public java.lang.String getErrorMessage()
public void run()
|
WebLogic Integration | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |