Class AProcessListener

  • All Implemented Interfaces:
    IProcessListener, org.api4.java.common.control.ILoggingCustomizable
    Direct Known Subclasses:
    DefaultProcessListener

    public abstract class AProcessListener
    extends java.lang.Object
    implements IProcessListener, org.api4.java.common.control.ILoggingCustomizable
    The process listener may be attached to a process in order to handle its ouputs streams in a controlled way. For instance, the process listener can be used to pipe all outputs of the invoked process to a logger system.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AProcessListener()  
      protected AProcessListener​(boolean listenForPIDFromProcess)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getLoggerName()  
      abstract void handleError​(java.lang.String error)
      Handle the output of the error output stream.
      abstract void handleInput​(java.lang.String input)
      Handle the output of the standard output stream.
      void listenTo​(java.lang.Process process)
      Lets the process listener listen to the output and error stream of the given process.
      void setLoggerName​(java.lang.String name)  
      • Methods inherited from class java.lang.Object

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

      • AProcessListener

        protected AProcessListener()
      • AProcessListener

        protected AProcessListener​(boolean listenForPIDFromProcess)
    • Method Detail

      • listenTo

        public void listenTo​(java.lang.Process process)
                      throws java.io.IOException,
                             java.lang.InterruptedException
        Description copied from interface: IProcessListener
        Lets the process listener listen to the output and error stream of the given process.
        Specified by:
        listenTo in interface IProcessListener
        Parameters:
        process - The process to be listened to.
        Throws:
        java.io.IOException
        java.lang.InterruptedException
      • handleError

        public abstract void handleError​(java.lang.String error)
                                  throws java.io.IOException,
                                         java.lang.InterruptedException
        Handle the output of the error output stream.
        Parameters:
        error - The line sent by the process via the error stream.
        Throws:
        java.io.IOException - An IOException is thrown if there is an issue reading from the process's stream.
        java.lang.InterruptedException - An interrupted exception is thrown if the thread/process is interrupted while processing the error messages.
      • handleInput

        public abstract void handleInput​(java.lang.String input)
                                  throws java.io.IOException,
                                         java.lang.InterruptedException
        Handle the output of the standard output stream.
        Parameters:
        error - The line sent by the process via the standard output stream.
        Throws:
        java.io.IOException - An IOException is thrown if there is an issue reading from the process's stream.
        java.lang.InterruptedException - An interrupted exception is thrown if the thread/process is interrupted while processing the standard output messages.
      • getLoggerName

        public java.lang.String getLoggerName()
        Specified by:
        getLoggerName in interface org.api4.java.common.control.ILoggingCustomizable
      • setLoggerName

        public void setLoggerName​(java.lang.String name)
        Specified by:
        setLoggerName in interface org.api4.java.common.control.ILoggingCustomizable