Class ProcessWrapper

java.lang.Object
org.jppf.process.ProcessWrapper

public final class ProcessWrapper extends Object
Wrapper around an external process started with ProcessBuilder. Instances of this class read the output ands error streams generated by the process and provide a notification mechanism with separate events for the respective streams.
Author:
Laurent Cohen
  • Field Details

  • Constructor Details

    • ProcessWrapper

      public ProcessWrapper()
      Initialize this process handler.
    • ProcessWrapper

      public ProcessWrapper(Process process)
      Initialize this process handler with the specified process.
      Parameters:
      process - the process to handle.
  • Method Details

    • getProcess

      public Process getProcess()
      Get the process to handle.
      Returns:
      a Process instance.
    • setProcess

      public void setProcess(Process process)
      Set the process to handle. If the process has already been set through this setter or the corresponding constructor, this method does nothing.
      Parameters:
      process - - a Process instance.
    • addListener

      public void addListener(ProcessWrapperEventListener listener)
      Add a listener to the list of listeners.
      Parameters:
      listener - the listener to add to the list.
    • removeListener

      public void removeListener(ProcessWrapperEventListener listener)
      Remove a listener from the list of listeners.
      Parameters:
      listener - the listener to remove from the list.
    • fireStreamEvent

      protected void fireStreamEvent(boolean output, String content)
      Notify all listeners that a stream event has occurred.
      Parameters:
      output - true if the event is for the output stream, false if it is for the error stream.
      content - the text that written to the stream.
    • setName

      public void setName(String name)
      Give a name to this object.
      Parameters:
      name - the object's name.