Package it.tidalwave.util.spi
Class DefaultProcessExecutor
java.lang.Object
it.tidalwave.util.spi.DefaultProcessExecutor
- All Implemented Interfaces:
ProcessExecutor
- Since:
- 1.39
- Author:
- Fabrizio Giudici
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface it.tidalwave.util.ProcessExecutor
ProcessExecutor.ConsoleOutput -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DefaultProcessExecutorforExecutable(String executable) Factory method for associating an executable.Sends a string to the stdin of the running process.start()Starts the external process.voidstop()Stops the external process.Waits for the termination of the external process.withArgument(String argument) Adds a single argument to pass to the external process.withArguments(String... arguments) Adds some arguments to pass to the external process.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface it.tidalwave.util.ProcessExecutor
getStderr, getStdout
-
Constructor Details
-
DefaultProcessExecutor
public DefaultProcessExecutor()
-
-
Method Details
-
forExecutable
Factory method for associating an executable. It returns an intermediate executor that must be configured and later started. Under Windows, the '.exe' suffix is automatically appended to the name of the executable.- Parameters:
executable- the executable (with the full path)- Returns:
- the executor
- See Also:
-
withArgument
Adds a single argument to pass to the external process.- Specified by:
withArgumentin interfaceProcessExecutor- Parameters:
argument- the argument- Returns:
- itself for chaining methods
-
withArguments
Adds some arguments to pass to the external process.- Specified by:
withArgumentsin interfaceProcessExecutor- Parameters:
arguments- the arguments- Returns:
- itself for chaining methods
-
start
Starts the external process.- Specified by:
startin interfaceProcessExecutor- Returns:
- itself for chaining methods
- Throws:
IOException- in case of error
-
stop
public void stop()Stops the external process.- Specified by:
stopin interfaceProcessExecutor
-
waitForCompletion
Waits for the termination of the external process.- Specified by:
waitForCompletionin interfaceProcessExecutor- Returns:
- itself for chaining methods
- Throws:
InterruptedException- if the wait has been interrupted
-
send
Sends a string to the stdin of the running process. If a carriage return is needed, it must be explicitly placed in the string.- Specified by:
sendin interfaceProcessExecutor- Parameters:
string- the string to send- Returns:
- itself for chaining methods
-