Class ProcessHandler<T>
java.lang.Object
com.github.kokorin.jaffree.process.ProcessHandler<T>
- Type Parameters:
T- process execution result
ProcessHandler executes program.
To read stdout and stderr configure StdReaders
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexecute()Executes a program.protected TinteractWithProcess(Process process) Interacts withProcess: reads stderr and stdout.protected static StringjoinArguments(List<String> arguments) setArguments(List<String> arguments) Sets arguments list to pass to a program.voidsetExecutorTimeoutMillis(int executorTimeoutMillis) Overrides the default Executor timeout.setHelpers(List<ProcessHelper> helpers) Set extraProcessHelpersthat must be executed in parallel with process.setStdErrReader(StdReader<T> stdErrReader) Sets stderr reader.setStdOutReader(StdReader<T> stdOutReader) Sets stdout reader.setStopper(Stopper stopper) SetsStopperwhich can be used to interrupt program execution.protected ExecutorstartExecution(Process process, AtomicReference<T> resultReference) Starts execution of stdout and stderrreadersas well asProcessHelpers.
-
Constructor Details
-
ProcessHandler
CreateProcessHandler.- Parameters:
executable- path to executablecontextName- logging context
-
-
Method Details
-
setStdOutReader
Sets stdout reader.- Parameters:
stdOutReader- stdout reader- Returns:
- this
-
setStdErrReader
Sets stderr reader.- Parameters:
stdErrReader- stdout reader- Returns:
- this
-
setHelpers
Set extraProcessHelpersthat must be executed in parallel with process.- Parameters:
helpers- helpers list- Returns:
- this
-
setStopper
SetsStopperwhich can be used to interrupt program execution.- Parameters:
stopper- stopper- Returns:
- this
-
setArguments
Sets arguments list to pass to a program.- Parameters:
arguments- arguments list- Returns:
- this
-
setExecutorTimeoutMillis
public void setExecutorTimeoutMillis(int executorTimeoutMillis) Overrides the default Executor timeout.A value of 0 is interpreted as "wait indefinitely".
- Parameters:
executorTimeoutMillis- the new Executor timeout in milliseconds
-
execute
Executes a program.Returns program result from stdout or stderr
readers.- Returns:
- program result
-
interactWithProcess
Interacts withProcess: reads stderr and stdout.- Parameters:
process- process- Returns:
- program result
-
startExecution
- Parameters:
process- processresultReference- reference to set result- Returns:
- executor
-
joinArguments
-