Class ProcessExecutor


  • public class ProcessExecutor
    extends java.lang.Object
    Configurable system command executor that captures stdout and stderr.
    Author:
    gjoranv, bjorncs
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int timeoutSeconds  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<ProcessResult> execute​(java.lang.String command)
      Convenience method to execute a process with no input data.
      java.util.Optional<ProcessResult> execute​(java.lang.String command, java.lang.String processInput)
      Executes the given command synchronously.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • timeoutSeconds

        public final int timeoutSeconds
    • Method Detail

      • execute

        public java.util.Optional<ProcessResult> execute​(java.lang.String command)
                                                  throws java.io.IOException
        Convenience method to execute a process with no input data. See execute(String, String) for details.
        Throws:
        java.io.IOException
      • execute

        public java.util.Optional<ProcessResult> execute​(java.lang.String command,
                                                         java.lang.String processInput)
                                                  throws java.io.IOException
        Executes the given command synchronously.
        Parameters:
        command - The command to execute.
        processInput - Input provided to the process.
        Returns:
        The result of the execution, or empty if the process does not terminate within the timeout set for this executor.
        Throws:
        java.io.IOException - if the process execution failed.