|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Executor
The main abstraction to start an external process. The interface allows to
Executor exec = new DefaultExecutor(); CommandLine cl = new CommandLine("ls -l"); int exitvalue = exec.execute(cl);
Field Summary | |
---|---|
static int |
INVALID_EXITVALUE
Invalid exit code. |
Method Summary | |
---|---|
int |
execute(CommandLine command)
Methods for starting synchronous execution. |
void |
execute(CommandLine command,
ExecuteResultHandler handler)
Methods for starting asynchronous execution. |
int |
execute(CommandLine command,
Map environment)
Methods for starting synchronous execution. |
void |
execute(CommandLine command,
Map environment,
ExecuteResultHandler handler)
Methods for starting asynchronous execution. |
ProcessDestroyer |
getProcessDestroyer()
Set the handler for cleanup of started processes if the main process is going to terminate. |
ExecuteStreamHandler |
getStreamHandler()
Get the StreamHandler used for providing input and retriving the output. |
ExecuteWatchdog |
getWatchdog()
Get the watchdog used to kill of processes running, typically, too long time. |
File |
getWorkingDirectory()
Get the working directory of the created process. |
boolean |
isFailure(int exitValue)
Checks whether exitValue signals a failure. |
void |
setExitValue(int value)
Define the exit code of the process to considered successful. |
void |
setExitValues(int[] values)
Define the exit code of the process to considered successful. |
void |
setProcessDestroyer(ProcessDestroyer processDestroyer)
Get the handler for cleanup of started processes if the main process is going to terminate. |
void |
setStreamHandler(ExecuteStreamHandler streamHandler)
Set the StreamHandler used for providing input and retriving the output. |
void |
setWatchdog(ExecuteWatchdog watchDog)
Set the watchdog used to kill of processes running, typically, too long time. |
void |
setWorkingDirectory(File dir)
Set the working directory of the created process. |
Field Detail |
---|
static final int INVALID_EXITVALUE
Method Detail |
---|
void setExitValue(int value)
value
- the exit code representing successful executionvoid setExitValues(int[] values)
values
- a list of the exit codesboolean isFailure(int exitValue)
exitValue
signals a failure. If no
exit values are set than the default conventions of the OS is
used. e.g. most OS regard an exit code of '0' as successful
execution and everything else as failure.
exitValue
- the exit value (return code) to be checked
true
if exitValue
signals a failureExecuteStreamHandler getStreamHandler()
void setStreamHandler(ExecuteStreamHandler streamHandler)
streamHandler
- the StreamHandlerExecuteWatchdog getWatchdog()
void setWatchdog(ExecuteWatchdog watchDog)
watchDog
- the watchdogProcessDestroyer getProcessDestroyer()
void setProcessDestroyer(ProcessDestroyer processDestroyer)
processDestroyer
- the ProcessDestroyerFile getWorkingDirectory()
void setWorkingDirectory(File dir)
dir
- the working directoryint execute(CommandLine command) throws ExecuteException, IOException
command
- the command to execute
ExecuteException
- execution of subprocess failed
IOException
int execute(CommandLine command, Map environment) throws ExecuteException, IOException
command
- the command to executeenvironment
- The environment for the new process. If null, the
environment of the current process is used.
ExecuteException
- execution of subprocess failed
IOException
void execute(CommandLine command, ExecuteResultHandler handler) throws ExecuteException, IOException
command
- the command to executehandler
- capture process termination and exit code
ExecuteException
- execution of subprocess failed
IOException
void execute(CommandLine command, Map environment, ExecuteResultHandler handler) throws ExecuteException, IOException
command
- the command to executeenvironment
- The environment for the new process. If null, the
environment of the current process is used.handler
- capture process termination and exit code
ExecuteException
- execution of subprocess failed
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |