Class 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 Detail

      • Launcher

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

      • 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
      • 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:
        ProcessBuilder.environment()
      • 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:
        ProcessBuilder.environment()
      • 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