Class LocalCommandRunner

  • All Implemented Interfaces:
    CommandRunner

    public class LocalCommandRunner
    extends Object
    implements CommandRunner
    Run a command on the local machine using a locally started process.
    • Constructor Detail

      • LocalCommandRunner

        public LocalCommandRunner()
    • Method Detail

      • initialize

        public void initialize()
        Description copied from interface: CommandRunner
        Initialization required before executing a command.
        Specified by:
        initialize in interface CommandRunner
      • runCommand

        public int runCommand​(List<String> args,
                              InputStream stdIn,
                              OutputStream stdOut,
                              OutputStream stdErr)
                       throws IOException
        Description copied from interface: CommandRunner
        Run the specified command. The given input stream is passed to the command as it's standard input. The standard output and standard error are captured in the given output streams. The exit code of the command as passed by the execution shell is returned.
        Specified by:
        runCommand in interface CommandRunner
        Parameters:
        args - list of arguments for the command line execution
        stdIn - input stream used as standard in
        stdOut - output stream that captures standard out
        stdErr - output stream that captures standard err
        Returns:
        exit code of the shell command
        Throws:
        IOException - thrown if any errors occur
      • dispose

        public void dispose()
        Description copied from interface: CommandRunner
        Clean up any resources that were acquired to execute shell commands. This method should always be called even if any errors occur running shell commands.
        Specified by:
        dispose in interface CommandRunner