Class AbstractProcessRunnable

  • All Implemented Interfaces:
    java.lang.Runnable
    Direct Known Subclasses:
    AbstractProcessReader

    public abstract class AbstractProcessRunnable
    extends java.lang.Object
    implements java.lang.Runnable
    Ancestor for runnables that use a Process object.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.Process m_Process
      the process to read from.
      protected java.util.concurrent.BlockingQueue<java.lang.Process> m_Queue
      the blocking queue for the process.
      protected boolean m_Stopped
      whether the reader got stopped.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract void doRun()
      The actual processing loop.
      java.lang.Process getProcess()
      Returns the underlying Process object.
      boolean isStopped()
      Returns whether execution got stopped.
      protected void logError​(java.lang.String msg)
      Just outputs the message on stderr.
      protected void logError​(java.lang.String msg, java.lang.Throwable t)
      Just outputs message and throwable on stderr.
      void run()
      Reads the data from the process.
      void setProcess​(java.lang.Process value)
      Sets the process to monitor.
      void stopExecution()
      Stops the execution.
      • Methods inherited from class java.lang.Object

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

      • m_Queue

        protected java.util.concurrent.BlockingQueue<java.lang.Process> m_Queue
        the blocking queue for the process.
      • m_Process

        protected java.lang.Process m_Process
        the process to read from.
      • m_Stopped

        protected boolean m_Stopped
        whether the reader got stopped.
    • Constructor Detail

      • AbstractProcessRunnable

        public AbstractProcessRunnable()
        Initializes the reader.
    • Method Detail

      • stopExecution

        public void stopExecution()
        Stops the execution.
      • isStopped

        public boolean isStopped()
        Returns whether execution got stopped.
        Returns:
        true if stopped
      • setProcess

        public void setProcess​(java.lang.Process value)
        Sets the process to monitor.
        Parameters:
        value - the process object
      • getProcess

        public java.lang.Process getProcess()
        Returns the underlying Process object.
        Returns:
        the process object, null if none set
      • logError

        protected void logError​(java.lang.String msg)
        Just outputs the message on stderr.
        Parameters:
        msg - the message to output
      • logError

        protected void logError​(java.lang.String msg,
                                java.lang.Throwable t)
        Just outputs message and throwable on stderr.
        Parameters:
        msg - the message to output
        t - the exception
      • doRun

        protected abstract void doRun()
        The actual processing loop.
      • run

        public void run()
        Reads the data from the process.
        Specified by:
        run in interface java.lang.Runnable