类 DefaultExecutor
java.lang.Object
com.sh.common.exec.DefaultExecutor
- 所有已实现的接口:
Executor
Description: 提供一些常用的方法用来执行外部进程
Title:首亨软件 - CRM、TSS、ERP等信息化管理软件
-
字段概要
从接口继承的字段 com.sh.common.exec.Executor
INVALID_EXITVALUE -
构造器概要
构造器构造器说明Default constructor creating a defaultPumpStreamHandlerand sets the working directory of the subprocess to the current working directory.DefaultExecutor(ExecuteStreamHandler streamHandler) -
方法概要
修饰符和类型方法说明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.protected ThreadGet the worker thread being used for 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.protected Processlaunch(CommandLine command, Map env, File dir) Creates a process that runs a command.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.voidsetWaitFor(boolean waitFor) 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.
-
构造器详细资料
-
DefaultExecutor
public DefaultExecutor()Default constructor creating a defaultPumpStreamHandlerand sets the working directory of the subprocess to the current working directory. ThePumpStreamHandlerpumps the output of the subprocess into ourSystem.outandSystem.errto avoid into ourSystem.outandSystem.errto avoid a blocked or deadlocked subprocess (seeProcess). -
DefaultExecutor
-
-
方法详细资料
-
setWaitFor
public void setWaitFor(boolean waitFor) -
getStreamHandler
从接口复制的说明:ExecutorGet the StreamHandler used for providing input and retrieving the output.- 指定者:
getStreamHandler在接口中Executor- 返回:
- the StreamHandler
- 另请参阅:
-
setStreamHandler
从接口复制的说明:ExecutorSet 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).- 指定者:
setStreamHandler在接口中Executor- 参数:
streamHandler- the stream handler- 另请参阅:
-
getWatchdog
从接口复制的说明:ExecutorGet the watchdog used to kill of processes running, typically, too long time.- 指定者:
getWatchdog在接口中Executor- 返回:
- the watchdog
- 另请参阅:
-
setWatchdog
从接口复制的说明:ExecutorSet the watchdog used to kill of processes running, typically, too long time.- 指定者:
setWatchdog在接口中Executor- 参数:
watchDog- the watchdog- 另请参阅:
-
getProcessDestroyer
从接口复制的说明:ExecutorSet the handler for cleanup of started processes if the main process is going to terminate.- 指定者:
getProcessDestroyer在接口中Executor- 返回:
- the ProcessDestroyer
- 另请参阅:
-
setProcessDestroyer
从接口复制的说明:ExecutorGet the handler for cleanup of started processes if the main process is going to terminate.- 指定者:
setProcessDestroyer在接口中Executor- 参数:
processDestroyer- the ProcessDestroyer- 另请参阅:
-
getWorkingDirectory
从接口复制的说明:ExecutorGet the working directory of the created process.- 指定者:
getWorkingDirectory在接口中Executor- 返回:
- the working directory
- 另请参阅:
-
setWorkingDirectory
从接口复制的说明:ExecutorSet the working directory of the created process. The working directory must exist when you start the process.- 指定者:
setWorkingDirectory在接口中Executor- 参数:
dir- the working directory- 另请参阅:
-
execute
从接口复制的说明:ExecutorMethods for starting synchronous execution. The child process inherits all environment variables of the parent process.- 指定者:
execute在接口中Executor- 参数:
command- the command to execute- 返回:
- process exit value
- 抛出:
ExecuteException- execution of subprocess failed or the subprocess returned a exit value indicating a failureExecutor.setExitValue(int).IOException- 另请参阅:
-
execute
从接口复制的说明:ExecutorMethods for starting synchronous execution.- 指定者:
execute在接口中Executor- 参数:
environment- 追加的环境变量command- the command to execute- 返回:
- process exit value
- 抛出:
ExecuteException- execution of subprocess failed or the subprocess returned a exit value indicating a failureExecutor.setExitValue(int).IOException- 另请参阅:
-
execute
public void execute(CommandLine command, ExecuteResultHandler handler) throws ExecuteException, IOException 从接口复制的说明:ExecutorMethods for starting asynchronous execution. The child process inherits all environment variables of the parent process. Result provided to callback handler.- 指定者:
execute在接口中Executor- 参数:
command- the command to executehandler- capture process termination and exit code- 抛出:
ExecuteException- execution of subprocess failedIOException- 另请参阅:
-
execute
public void execute(CommandLine command, Map environment, ExecuteResultHandler handler) throws ExecuteException, IOException 从接口复制的说明:ExecutorMethods for starting asynchronous execution. The child process inherits all environment variables of the parent process. Result provided to callback handler.- 指定者:
execute在接口中Executor- 参数:
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- 另请参阅:
-
setExitValue
public void setExitValue(int value) 从接口复制的说明:ExecutorDefine theexitValueof the process to be considered successful. If a different exit value is returned by the process thenExecutor.execute(CommandLine)will throw anExecuteException- 指定者:
setExitValue在接口中Executor- 参数:
value- the exit code representing successful execution- 另请参阅:
-
setExitValues
public void setExitValues(int[] values) 从接口复制的说明:ExecutorDefine 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
Executor.isFailure(int) - null to indicate to skip checking of exit codes
Executor.execute(CommandLine)will throw anExecuteException.- 指定者:
setExitValues在接口中Executor- 参数:
values- a list of the exit codes- 另请参阅:
-
isFailure
public boolean isFailure(int exitValue) 从接口复制的说明:ExecutorChecks 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. -
launch
Creates a process that runs a command.- 参数:
command- the command to runenv- the environment for the commanddir- the working directory for the command- 返回:
- the process started
- 抛出:
IOException- forwarded from the particular launcher used
-
getExecutorThread
Get the worker thread being used for asynchronous execution.- 返回:
- the worker thread
-