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 classes/interfaces inherited from interface it.tidalwave.util.ProcessExecutor
ProcessExecutor.ConsoleOutput
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic DefaultProcessExecutor
forExecutable
(String executable) Factory method for associating an executable.Sends a string to the stdin of the running process.start()
Starts the external process.void
stop()
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, wait
Methods 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:
withArgument
in interfaceProcessExecutor
- Parameters:
argument
- the argument- Returns:
- itself for chaining methods
-
withArguments
Adds some arguments to pass to the external process.- Specified by:
withArguments
in interfaceProcessExecutor
- Parameters:
arguments
- the arguments- Returns:
- itself for chaining methods
-
start
Starts the external process.- Specified by:
start
in interfaceProcessExecutor
- Returns:
- itself for chaining methods
- Throws:
IOException
- in case of error
-
stop
public void stop()Stops the external process.- Specified by:
stop
in interfaceProcessExecutor
-
waitForCompletion
Waits for the termination of the external process.- Specified by:
waitForCompletion
in 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:
send
in interfaceProcessExecutor
- Parameters:
string
- the string to send- Returns:
- itself for chaining methods
-