接口 Executor
- 所有已知实现类:
DefaultExecutor
public interface Executor
Description:
Title:首亨软件 - CRM、TSS、ERP等信息化管理软件
-
字段概要
字段 -
方法概要
修饰符和类型方法说明intexecute(CommandLine command) Methods for starting synchronous execution.voidexecute(CommandLine command, ExecuteResultHandler handler) Methods for starting asynchronous execution.intexecute(CommandLine command, Map environment) Methods for starting synchronous execution.voidexecute(CommandLine command, Map environment, ExecuteResultHandler handler) Methods for starting asynchronous execution.Set the handler for cleanup of started processes if the main process is going to terminate.Get the StreamHandler used for providing input and retrieving the output.Get the watchdog used to kill of processes running, typically, too long time.Get the working directory of the created process.booleanisFailure(int exitValue) Checks whetherexitValuesignals a failure.voidsetExitValue(int value) Define theexitValueof the process to be considered successful.voidsetExitValues(int[] values) Define a list ofexitValueof the process to be considered successful.voidsetProcessDestroyer(ProcessDestroyer processDestroyer) Get the handler for cleanup of started processes if the main process is going to terminate.voidsetStreamHandler(ExecuteStreamHandler streamHandler) Set a custom the StreamHandler used for providing input and retrieving the output.voidsetWatchdog(ExecuteWatchdog watchDog) Set the watchdog used to kill of processes running, typically, too long time.voidsetWorkingDirectory(File dir) Set the working directory of the created process.
-
字段详细资料
-
INVALID_EXITVALUE
static final int INVALID_EXITVALUEInvalid exit code.- 另请参阅:
-
-
方法详细资料
-
setExitValue
void setExitValue(int value) Define theexitValueof the process to be considered successful. If a different exit value is returned by the process thenexecute(CommandLine)will throw anExecuteException- 参数:
value- the exit code representing successful execution
-
setExitValues
void setExitValues(int[] values) Define a list ofexitValueof the process to be considered successful. The caller can pass one of the following values- an array of exit values to be considered successful
- an empty array for auto-detect of successful exit codes relying on
isFailure(int) - null to indicate to skip checking of exit codes
execute(CommandLine)will throw anExecuteException.- 参数:
values- a list of the exit codes
-
isFailure
boolean isFailure(int exitValue) Checks whetherexitValuesignals 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- 返回:
trueifexitValuesignals a failure
-
getStreamHandler
ExecuteStreamHandler getStreamHandler()Get the StreamHandler used for providing input and retrieving the output.- 返回:
- the StreamHandler
-
setStreamHandler
Set a custom the StreamHandler used for providing input and retrieving the output. If you don't provide a proper stream handler the executed process might block when writing to stdout and/or stderr (seeProcess).- 参数:
streamHandler- the stream handler
-
getWatchdog
ExecuteWatchdog getWatchdog()Get the watchdog used to kill of processes running, typically, too long time.- 返回:
- the watchdog
-
setWatchdog
Set the watchdog used to kill of processes running, typically, too long time.- 参数:
watchDog- the watchdog
-
getProcessDestroyer
ProcessDestroyer getProcessDestroyer()Set the handler for cleanup of started processes if the main process is going to terminate.- 返回:
- the ProcessDestroyer
-
setProcessDestroyer
Get the handler for cleanup of started processes if the main process is going to terminate.- 参数:
processDestroyer- the ProcessDestroyer
-
getWorkingDirectory
File getWorkingDirectory()Get the working directory of the created process.- 返回:
- the working directory
-
setWorkingDirectory
Set the working directory of the created process. The working directory must exist when you start the process.- 参数:
dir- the working directory
-
execute
Methods for starting synchronous execution. The child process inherits all environment variables of the parent process.- 参数:
command- the command to execute- 返回:
- process exit value
- 抛出:
ExecuteException- execution of subprocess failed or the subprocess returned a exit value indicating a failuresetExitValue(int).IOException
-
execute
Methods for starting synchronous execution.- 参数:
command- the command to executeenvironment- The environment for the new process. If null, the environment of the current process is used.- 返回:
- process exit value
- 抛出:
ExecuteException- execution of subprocess failed or the subprocess returned a exit value indicating a failuresetExitValue(int).IOException
-
execute
void execute(CommandLine command, ExecuteResultHandler handler) throws ExecuteException, IOException Methods for starting asynchronous execution. The child process inherits all environment variables of the parent process. Result provided to callback handler.- 参数:
command- the command to executehandler- capture process termination and exit code- 抛出:
ExecuteException- execution of subprocess failedIOException
-
execute
void execute(CommandLine command, Map environment, ExecuteResultHandler handler) throws ExecuteException, IOException Methods for starting asynchronous execution. The child process inherits all environment variables of the parent process. Result provided to callback handler.- 参数:
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 failedIOException
-