public class Launcher extends Object
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.Constructor and Description |
---|
Launcher(CommandBuilder builder)
Creates a new launcher.
|
Modifier and Type | Method and Description |
---|---|
Launcher |
addEnvironmentVariable(String key,
String value)
Adds an environment variable to the process being created.
|
Launcher |
addEnvironmentVariables(Map<String,String> env)
Adds the environment variables to the process being created.
|
Launcher |
inherit()
Sets the output and error streams to inherit the output and error streams from it's parent process.
|
Process |
launch()
Launches a new process based on the commands from the
builder . |
static Launcher |
of(CommandBuilder builder)
Creates a new launcher to create a
process based on the command builder. |
Launcher |
redirectError(File file)
Redirects the error stream of the process to a file.
|
Launcher |
redirectError(ProcessBuilder.Redirect destination)
Redirects the error stream of the process to the destination provided.
|
Launcher |
redirectOutput(File file)
Redirects the output of the process to a file.
|
Launcher |
redirectOutput(Path path)
Redirects the output of the process to a file.
|
Launcher |
redirectOutput(ProcessBuilder.Redirect destination)
Redirects the output of the process to the destination provided.
|
Launcher |
setDirectory(File dir)
Sets the working directory for the process created.
|
Launcher |
setDirectory(Path path)
Sets the working directory for the process created.
|
Launcher |
setDirectory(String dir)
Sets the working directory for the process created.
|
Launcher |
setRedirectErrorStream(boolean redirectErrorStream)
Set to
true if the error stream should be redirected to the output stream. |
public Launcher(CommandBuilder builder)
builder
- the builder to build the list of commandspublic static Launcher of(CommandBuilder builder)
process
based on the command builder.builder
- the builder used to launch the processpublic Launcher inherit()
public Launcher setRedirectErrorStream(boolean redirectErrorStream)
true
if the error stream should be redirected to the output stream.redirectErrorStream
- true
to merge the error stream into the output stream, otherwise false
to keep the streams separatepublic Launcher redirectOutput(File file)
file
- the file to redirect the output toProcessBuilder.Redirect.to(java.io.File)
public Launcher redirectOutput(Path path)
path
- the path to redirect the output toProcessBuilder.Redirect.to(java.io.File)
public Launcher redirectOutput(ProcessBuilder.Redirect destination)
destination
- the output destinationProcessBuilder.redirectOutput(java.lang.ProcessBuilder.Redirect)
public Launcher redirectError(File file)
file
- the file to redirect the error stream toProcessBuilder.Redirect.to(java.io.File)
public Launcher redirectError(ProcessBuilder.Redirect destination)
destination
- the error stream destinationProcessBuilder.redirectError(java.lang.ProcessBuilder.Redirect)
public Launcher setDirectory(Path path)
path
- the path to the working directoryProcessBuilder.directory(java.io.File)
public Launcher setDirectory(File dir)
dir
- the working directoryProcessBuilder.directory(java.io.File)
public Launcher setDirectory(String dir)
dir
- the working directoryProcessBuilder.directory(java.io.File)
public Launcher addEnvironmentVariable(String key, String value)
key
- they key for the variablevalue
- the value for the variablepublic Launcher addEnvironmentVariables(Map<String,String> env)
env
- the environment variables to addpublic Process launch() throws IOException
builder
.IOException
- if an error occurs launching the processCopyright © 2023 JBoss by Red Hat. All rights reserved.