Class AbstractProcessOutput

    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractProcessOutput()
      Starts the monitoring process.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract AbstractProcessReader configureStdErr()
      Configures the reader for stderr.
      protected abstract AbstractProcessReader configureStdOut()
      Configures the reader for stdout.
      protected AbstractProcessRunnable configureTimeOutMonitor()
      Configures the runnable for watching for time outs.
      void destroy()
      Destroys the process if possible.
      void flush()
      Flushes the readers.
      java.lang.String[] getCommand()
      Returns the command that was used for the process.
      java.lang.String[] getEnvironment()
      Returns the environment.
      int getExitCode()
      Returns the exit code.
      java.lang.Process getProcess()
      Returns the process.
      int getTimeOut()
      Returns the timeout for the process in seconds.
      boolean hasSucceeded()
      Returns whether the process has succeeded.
      boolean hasTimedOut()
      Returns whether the process timed out and got terminated.
      protected void initialize()
      For initializing the members.
      void monitor​(java.lang.ProcessBuilder builder)
      Performs the actual process monitoring.
      void monitor​(java.lang.String[] cmd, java.lang.String[] env, java.lang.String input, java.lang.Process process)
      Performs the actual process monitoring.
      void monitor​(java.lang.String input, java.lang.ProcessBuilder builder)
      Performs the actual process monitoring.
      void monitor​(java.lang.String cmd, java.lang.String[] env, java.lang.Process process)
      Performs the actual process monitoring.
      void monitor​(java.lang.String cmd, java.lang.String[] env, java.lang.String input, java.lang.Process process)
      Performs the actual process monitoring.
      void setTimeOut​(int value)
      Sets the timeout for the process in seconds.
      java.lang.String toString()
      Returns a short description string.
      • Methods inherited from class java.lang.Object

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

      • m_Command

        protected java.lang.String[] m_Command
        the command.
      • m_Environment

        protected java.lang.String[] m_Environment
        the environment variables.
      • m_ExitCode

        protected int m_ExitCode
        the exit code.
      • m_Process

        protected transient java.lang.Process m_Process
        the process.
      • m_TimeOut

        protected int m_TimeOut
        the timeout for the process in seconds (ignored if < 1).
      • m_TimedOut

        protected boolean m_TimedOut
        whether the process has timed out.
    • Constructor Detail

      • AbstractProcessOutput

        public AbstractProcessOutput()
        Starts the monitoring process.
    • Method Detail

      • initialize

        protected void initialize()
        For initializing the members.
      • setTimeOut

        public void setTimeOut​(int value)
        Sets the timeout for the process in seconds.
        Parameters:
        value - the timeout (less than 1 for no timeout)
      • getTimeOut

        public int getTimeOut()
        Returns the timeout for the process in seconds.
        Returns:
        the timeout (less than 1 for no timeout)
      • monitor

        public void monitor​(java.lang.ProcessBuilder builder)
                     throws java.lang.Exception
        Performs the actual process monitoring.
        Parameters:
        builder - the process builder to monitor
        Throws:
        java.lang.Exception - if writing to stdin fails
      • monitor

        public void monitor​(java.lang.String input,
                            java.lang.ProcessBuilder builder)
                     throws java.lang.Exception
        Performs the actual process monitoring.
        Parameters:
        builder - the process builder to monitor
        Throws:
        java.lang.Exception - if writing to stdin fails
      • monitor

        public void monitor​(java.lang.String cmd,
                            java.lang.String[] env,
                            java.lang.Process process)
                     throws java.lang.Exception
        Performs the actual process monitoring.
        Parameters:
        cmd - the command that was used
        env - the environment
        process - the process to monitor
        Throws:
        java.lang.Exception - if writing to stdin fails
      • monitor

        public void monitor​(java.lang.String cmd,
                            java.lang.String[] env,
                            java.lang.String input,
                            java.lang.Process process)
                     throws java.lang.Exception
        Performs the actual process monitoring.
        Parameters:
        cmd - the command that was used
        env - the environment
        input - the input to be written to the process via stdin, ignored if null
        process - the process to monitor
        Throws:
        java.lang.Exception - if writing to stdin fails
      • monitor

        public void monitor​(java.lang.String[] cmd,
                            java.lang.String[] env,
                            java.lang.String input,
                            java.lang.Process process)
                     throws java.lang.Exception
        Performs the actual process monitoring.
        Parameters:
        cmd - the command that was used
        env - the environment
        input - the input to be written to the process via stdin, ignored if null
        process - the process to monitor
        Throws:
        java.lang.Exception - if writing to stdin fails
      • configureStdErr

        protected abstract AbstractProcessReader configureStdErr()
        Configures the reader for stderr.
        Returns:
        the configured reader
      • configureStdOut

        protected abstract AbstractProcessReader configureStdOut()
        Configures the reader for stdout.
        Returns:
        the configured reader
      • configureTimeOutMonitor

        protected AbstractProcessRunnable configureTimeOutMonitor()
        Configures the runnable for watching for time outs.
        Returns:
        the configured runnable
      • getCommand

        public java.lang.String[] getCommand()
        Returns the command that was used for the process.
        Returns:
        the command
      • getEnvironment

        public java.lang.String[] getEnvironment()
        Returns the environment.
        Returns:
        the environment, null if process inherited current one
      • hasSucceeded

        public boolean hasSucceeded()
        Returns whether the process has succeeded.
        Returns:
        true if succeeded, i.e., exit code = 0 and not timedout
        See Also:
        hasTimedOut()
      • getExitCode

        public int getExitCode()
        Returns the exit code.
        Returns:
        the exit code
      • hasTimedOut

        public boolean hasTimedOut()
        Returns whether the process timed out and got terminated.
        Returns:
        true if timedout
        See Also:
        getTimeOut(), setTimeOut(int)
      • getProcess

        public java.lang.Process getProcess()
        Returns the process.
        Returns:
        the process, null if not available
      • flush

        public void flush()
        Flushes the readers.
      • destroy

        public void destroy()
        Destroys the process if possible.
      • toString

        public java.lang.String toString()
        Returns a short description string.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the description