ManagedProcessBuilder

Builder for ManagedProcess.

This is inspired by java.lang.ProcessBuilder&CommandLine, and/but:

It offers to add java.nio.Path arguments, and makes sure that their absolute path is used.

If no directory is set, it automatically sets the initial working directory using the directory of executable if it was a Path, and thus makes sure an initial working directory is always passed to the process.

It intentionally doesn't offer "parsing" space delimited command "lines", but forces you to set an executable and add arguments.

Author

Michael Vorburger

Neelesh Shastry

William Dutton

Constructors

Link copied to clipboard
public void ManagedProcessBuilder(String executable)
Creates a builder for the given executable path (string form).
public void ManagedProcessBuilder(Path executable)
Creates a builder for the given executable path.

Functions

Link copied to clipboard
Adds an argument to the command.
Adds a Path as an argument to the command.
public ManagedProcessBuilder addArgument(String arg, boolean handleQuoting)
Adds a raw argument to the command.
public ManagedProcessBuilder addArgument(String argPart1, String argPart2)
Adds a single argument to the command, composed of two parts.
Link copied to clipboard
Adds a single argument to the command, composed of a prefix and a file path separated by "=".
Link copied to clipboard
Adds an extra stream to receive STDERR from the process.
Link copied to clipboard
Adds an extra stream to receive STDOUT from the process.
Link copied to clipboard
Builds a ManagedProcess from the current configuration.
Link copied to clipboard
Returns the current list of arguments (after quoting/escaping).
Link copied to clipboard
Returns the number of console lines retained for diagnostics.
Link copied to clipboard
Returns the environment variables that will be passed to the launched process.
Link copied to clipboard
Returns the executable path string that will be launched.
Link copied to clipboard
Returns the dispatcher that determines the SLF4J log level (or suppression) for each STDOUT/STDERR line.
Link copied to clipboard
@Nullable()
public @Nullable() ManagedProcessListener getProcessListener()
Returns the currently configured process listener.
Link copied to clipboard
@Nullable()
public @Nullable() Path getWorkingDirectory()
Returns the working directory that will be used for the launched process.
Link copied to clipboard
public boolean isDestroyOnShutdown()
Returns whether the process will be destroyed automatically on JVM shutdown.
Link copied to clipboard
public ManagedProcessBuilder setConsoleBufferMaxLines(int consoleBufferMaxLines)
Sets the number of console lines to retain for diagnostics.
Link copied to clipboard
Enables or disables destroying the process when the JVM shuts down.
Link copied to clipboard
public ManagedProcessBuilder setInputStream(@Nullable() @Nullable() InputStream inputStream)
Provides an input stream which will be fed to the process' STDIN.
Link copied to clipboard
Sets the predicate that determines whether an exit value is considered success.
Link copied to clipboard
Sets the dispatcher that determines the SLF4J log level (or suppression) for each line emitted on STDOUT/STDERR by the managed process.
Link copied to clipboard
public ManagedProcessBuilder setProcessListener(@Nullable() @Nullable() ManagedProcessListener listener)
Sets the process listener to be notified of lifecycle events.
Link copied to clipboard
public ManagedProcessBuilder setWorkingDirectory(@Nullable() @Nullable() Path directory)
Sets working directory.
Link copied to clipboard
public String toString()
Intended for debugging / logging, only.