java.lang.Object
org.wildfly.core.launcher.Launcher
Builds a
process to launch a standalone or domain server based on the command builder.
The process is only created by the launcher and not managed. It's the responsibility of the consumer to manage the
process.- Author:
- James R. Perkins
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddEnvironmentVariable(String key, String value) Adds an environment variable to the process being created.Adds the environment variables to the process being created.inherit()Sets the output and error streams to inherit the output and error streams from it's parent process.launch()Launches a new process based on the commands from thebuilder.static Launcherof(CommandBuilder builder) Creates a new launcher to create aprocessbased on the command builder.redirectError(File file) Redirects the error stream of the process to a file.redirectError(ProcessBuilder.Redirect destination) Redirects the error stream of the process to the destination provided.redirectOutput(File file) Redirects the output of the process to a file.redirectOutput(ProcessBuilder.Redirect destination) Redirects the output of the process to the destination provided.redirectOutput(Path path) Redirects the output of the process to a file.setDirectory(File dir) Sets the working directory for the process created.setDirectory(String dir) Sets the working directory for the process created.setDirectory(Path path) Sets the working directory for the process created.setRedirectErrorStream(boolean redirectErrorStream) Set totrueif the error stream should be redirected to the output stream.
-
Constructor Details
-
Launcher
Creates a new launcher.- Parameters:
builder- the builder to build the list of commands
-
-
Method Details
-
of
Creates a new launcher to create aprocessbased on the command builder.- Parameters:
builder- the builder used to launch the process- Returns:
- the newly created launcher
-
inherit
Sets the output and error streams to inherit the output and error streams from it's parent process.- Returns:
- the launcher
-
setRedirectErrorStream
Set totrueif the error stream should be redirected to the output stream.- Parameters:
redirectErrorStream-trueto merge the error stream into the output stream, otherwisefalseto keep the streams separate- Returns:
- the launcher
-
redirectOutput
Redirects the output of the process to a file.- Parameters:
file- the file to redirect the output to- Returns:
- the launcher
- See Also:
-
redirectOutput
Redirects the output of the process to a file.- Parameters:
path- the path to redirect the output to- Returns:
- the launcher
- See Also:
-
redirectOutput
Redirects the output of the process to the destination provided.- Parameters:
destination- the output destination- Returns:
- the launcher
- See Also:
-
redirectError
Redirects the error stream of the process to a file.- Parameters:
file- the file to redirect the error stream to- Returns:
- the launcher
- See Also:
-
redirectError
Redirects the error stream of the process to the destination provided.- Parameters:
destination- the error stream destination- Returns:
- the launcher
- See Also:
-
setDirectory
Sets the working directory for the process created.- Parameters:
path- the path to the working directory- Returns:
- the launcher
- See Also:
-
setDirectory
Sets the working directory for the process created.- Parameters:
dir- the working directory- Returns:
- the launcher
- See Also:
-
setDirectory
Sets the working directory for the process created.- Parameters:
dir- the working directory- Returns:
- the launcher
- See Also:
-
addEnvironmentVariable
Adds an environment variable to the process being created. If the key or value isnull, the environment variable will not be added.- Parameters:
key- they key for the variablevalue- the value for the variable- Returns:
- the launcher
- See Also:
-
addEnvironmentVariables
Adds the environment variables to the process being created. Note thatnullkeys or values will not be added.- Parameters:
env- the environment variables to add- Returns:
- the launcher
- See Also:
-
launch
Launches a new process based on the commands from thebuilder.- Returns:
- the newly created process
- Throws:
IOException- if an error occurs launching the process
-