|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.exec.DefaultExecutor
public class DefaultExecutor
The default class to start a subprocess. The implementation allows to
Executor exec = new DefaultExecutor();
CommandLine cl = new CommandLine("ls -l");
int exitvalue = exec.execute(cl);
| Field Summary |
|---|
| Fields inherited from interface org.apache.commons.exec.Executor |
|---|
INVALID_EXITVALUE |
| Constructor Summary | |
|---|---|
DefaultExecutor()
Default Constrctor |
|
| 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. |
protected Process |
launch(CommandLine command,
Map env,
File dir)
Creates a process that runs a command. |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultExecutor()
| Method Detail |
|---|
public ExecuteStreamHandler getStreamHandler()
Executor
getStreamHandler in interface ExecutorExecutor.getStreamHandler()public void setStreamHandler(ExecuteStreamHandler streamHandler)
Executor
setStreamHandler in interface ExecutorstreamHandler - the StreamHandlerExecutor.setStreamHandler(org.apache.commons.exec.ExecuteStreamHandler)public ExecuteWatchdog getWatchdog()
Executor
getWatchdog in interface ExecutorExecutor.getWatchdog()public void setWatchdog(ExecuteWatchdog watchDog)
Executor
setWatchdog in interface ExecutorwatchDog - the watchdogExecutor.setWatchdog(org.apache.commons.exec.ExecuteWatchdog)public ProcessDestroyer getProcessDestroyer()
Executor
getProcessDestroyer in interface ExecutorExecutor.getProcessDestroyer()public void setProcessDestroyer(ProcessDestroyer processDestroyer)
Executor
setProcessDestroyer in interface ExecutorprocessDestroyer - the ProcessDestroyerExecutor.setProcessDestroyer(ProcessDestroyer)public File getWorkingDirectory()
Executor
getWorkingDirectory in interface ExecutorExecutor.getWorkingDirectory()public void setWorkingDirectory(File dir)
Executor
setWorkingDirectory in interface Executordir - the working directoryExecutor.setWorkingDirectory(java.io.File)
public int execute(CommandLine command)
throws ExecuteException,
IOException
Executor
execute in interface Executorcommand - the command to execute
ExecuteException - execution of subprocess failed
IOExceptionExecutor.execute(CommandLine)
public int execute(CommandLine command,
Map environment)
throws ExecuteException,
IOException
Executor
execute in interface Executorcommand - 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
IOExceptionExecutor.execute(CommandLine, java.util.Map)
public void execute(CommandLine command,
ExecuteResultHandler handler)
throws ExecuteException,
IOException
Executor
execute in interface Executorcommand - the command to executehandler - capture process termination and exit code
ExecuteException - execution of subprocess failed
IOExceptionExecutor.execute(CommandLine,
org.apache.commons.exec.ExecuteResultHandler)
public void execute(CommandLine command,
Map environment,
ExecuteResultHandler handler)
throws ExecuteException,
IOException
Executor
execute in interface Executorcommand - 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
IOExceptionExecutor.execute(CommandLine,
java.util.Map, org.apache.commons.exec.ExecuteResultHandler)public void setExitValue(int value)
Executor
setExitValue in interface Executorvalue - the exit code representing successful executionExecutor.setExitValue(int)public void setExitValues(int[] values)
Executor
setExitValues in interface Executorvalues - a list of the exit codesExecutor.setExitValues(int[])public boolean isFailure(int exitValue)
ExecutorexitValue 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.
isFailure in interface ExecutorexitValue - the exit value (return code) to be checked
true if exitValue signals a failureExecutor.isFailure(int)
protected Process launch(CommandLine command,
Map env,
File dir)
throws IOException
command - the command to runenv - the environment for the commanddir - the working directory for the command
IOException - forwarded from the particular launcher used
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||