Class Launcher

java.lang.Object
org.wildfly.core.launcher.Launcher

public class Launcher extends Object
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 Details

    • Launcher

      public Launcher(CommandBuilder builder)
      Creates a new launcher.
      Parameters:
      builder - the builder to build the list of commands
  • Method Details

    • of

      public static Launcher of(CommandBuilder builder)
      Creates a new launcher to create a process based on the command builder.
      Parameters:
      builder - the builder used to launch the process
      Returns:
      the newly created launcher
    • inherit

      public Launcher inherit()
      Sets the output and error streams to inherit the output and error streams from it's parent process.
      Returns:
      the launcher
    • setRedirectErrorStream

      public Launcher setRedirectErrorStream(boolean redirectErrorStream)
      Set to true if the error stream should be redirected to the output stream.
      Parameters:
      redirectErrorStream - true to merge the error stream into the output stream, otherwise false to keep the streams separate
      Returns:
      the launcher
    • redirectOutput

      public Launcher redirectOutput(File file)
      Redirects the output of the process to a file.
      Parameters:
      file - the file to redirect the output to
      Returns:
      the launcher
      See Also:
    • redirectOutput

      public Launcher redirectOutput(Path path)
      Redirects the output of the process to a file.
      Parameters:
      path - the path to redirect the output to
      Returns:
      the launcher
      See Also:
    • redirectOutput

      public Launcher redirectOutput(ProcessBuilder.Redirect destination)
      Redirects the output of the process to the destination provided.
      Parameters:
      destination - the output destination
      Returns:
      the launcher
      See Also:
    • redirectError

      public Launcher redirectError(File file)
      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

      public Launcher redirectError(ProcessBuilder.Redirect destination)
      Redirects the error stream of the process to the destination provided.
      Parameters:
      destination - the error stream destination
      Returns:
      the launcher
      See Also:
    • setDirectory

      public Launcher setDirectory(Path path)
      Sets the working directory for the process created.
      Parameters:
      path - the path to the working directory
      Returns:
      the launcher
      See Also:
    • setDirectory

      public Launcher setDirectory(File dir)
      Sets the working directory for the process created.
      Parameters:
      dir - the working directory
      Returns:
      the launcher
      See Also:
    • setDirectory

      public Launcher setDirectory(String dir)
      Sets the working directory for the process created.
      Parameters:
      dir - the working directory
      Returns:
      the launcher
      See Also:
    • addEnvironmentVariable

      public Launcher addEnvironmentVariable(String key, String value)
      Adds an environment variable to the process being created. If the key or value is null, the environment variable will not be added.
      Parameters:
      key - they key for the variable
      value - the value for the variable
      Returns:
      the launcher
      See Also:
    • addEnvironmentVariables

      public Launcher addEnvironmentVariables(Map<String,String> env)
      Adds the environment variables to the process being created. Note that null keys or values will not be added.
      Parameters:
      env - the environment variables to add
      Returns:
      the launcher
      See Also:
    • launch

      public Process launch() throws IOException
      Launches a new process based on the commands from the builder.
      Returns:
      the newly created process
      Throws:
      IOException - if an error occurs launching the process