Class FWPipeLine

java.lang.Object
java.lang.Thread
net.simplace.pipe.control.FWPipeLine
All Implemented Interfaces:
Runnable

public class FWPipeLine extends Thread
Represents a pipeline of processors, declared as <pipeline id="..."> with processor and parameter children and optional lockname / locktimedifference elements. The processors are run one after the other, each getting the observable returned by its predecessor. A pipeline can be run in its own thread (see FWLoopProcessor) or synchronously by calling run().

If a lock name is given, a lock file <temp dir root>/<lockname>.lock prevents that two pipelines with the same lock name run at the same time (a lock is ignored if older than the lock time difference).

Author:
Andreas Enders
  • Constructor Details

    • FWPipeLine

      public FWPipeLine(org.jdom2.Element aPipelineElement, FWPipeLinesContainer aContainer) throws PipeLineCreationException
      Constructs a pipeline from its XML element, creating all processors.
      Parameters:
      aPipelineElement - the pipeline element
      aContainer - the pipeline container the processors belong to
      Throws:
      PipeLineCreationException - if the id is missing or a processor cannot be created
  • Method Details

    • clone

      public FWPipeLine clone()
      Clones the pipeline with clones of its processors, its initial parameters and its lock settings.
      Overrides:
      clone in class Thread
    • prepare

      public void prepare(net.simplace.core.FWObservable aObservable, int aNumberOfSteps)
      Prepares the pipeline for running.
      Parameters:
      aObservable - the observable passed to the first processor
      aNumberOfSteps - maximum number of processors to run
    • getResult

      public net.simplace.core.FWObservable getResult()
      Called after the pipeline has finished.
      Returns:
      the observable returned by the last processor that was run
    • run

      public void run()
      Runs the processors in order with the prepared observable (plus the pipeline's initial parameters). Stops after an error, when the thread is interrupted, when a processor sets the end of pipe flag or when the maximum number of steps is reached. An error of a loop processor only interrupts the thread; an error of any other processor terminates the run and is kept for the caller (see getException()). Does nothing if the pipeline is locked.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • getException

      public PipeLineException getException()
      Returns:
      the error of a (non-loop) processor that terminated the last run, or null if the run ended normally
    • getProcessors

      public List<FWProcessor> getProcessors()
      Returns:
      the processors of the pipeline, in order
    • getAllreadyLoopedCount

      public int getAllreadyLoopedCount()
      Returns:
      the number of loops this pipeline was run through
    • setAllreadyLoopedCount

      public void setAllreadyLoopedCount(int allreadyLoopedCount)
      Parameters:
      allreadyLoopedCount - the number of loops already run