Class PumpEventService

All Implemented Interfaces:
CtxEventListener, ContextHandleAware, HandleAware, Ready, ReadyAndReadyListener, ReadyListener

public final class PumpEventService extends AbstractService
Service that distributes pump lifecycle events.
Since:
1.0
Version:
2024-08-22
  • Field Details

  • Method Details

    • lock

      public boolean lock(NozzlePipeline pipeline, Pump<?> pump, Object lock)
      Lock a pump relative to a pipeline referencing the specified lock object. The lock object should be some type of transaction object that a group of pumps share, such as a PumpIntent object. This object will be used to unlock all pumps locked against the object. This will generate a lock event to registered listeners.

      If a pump is locked more than once for the same lock it will be silently ignored. This allows applications to call lock on pumps more than once per lock, such as for each phase of a sequence of operations, which eliminates the need for applications to track locks.

      Once locked, a pump should be unlocked before being locked again using a different lock.

      Parameters:
      pipeline - the pipeline generating the event
      pump - the pump to lock
      lock - the lock object
      Returns:
      true if the pump was successfully locked
    • unlock

      public void unlock(Object lock)
      Unlock all pumps associated with the specified lock. This will generate an unlock event to registered listeners. If any of the pumps are still in a started state, a stop event will be generated before the unlock event. This ensures event symmetry.
      Parameters:
      lock - the lock object to release
    • lockExists

      public boolean lockExists(Object lock)
      Return true if the specified lock exists.
      Parameters:
      lock - the lock object to release
    • isRunning

      public boolean isRunning(Pump<?> pump)
      Return true if the specified pumps is in a running state
      Parameters:
      pump - the pump to check
    • start

      public void start(Pump<?> pump)
      Indicate that a pump has started, and fire a start event to registered listeners. If the pump is already started, this call will be ignored. This allows applications to safely call start multiple times.
      Parameters:
      pump - the pump that started
    • stop

      public void stop(Pump<?> pump)
      Indicate that a pump has stopped, and fire a stop event to registered listeners.
      Parameters:
      pump - the pump that stopped
    • replacePump

      public void replacePump(Pump<?> pump)
      Notify listeners that the specified pump has been replaced.
      Parameters:
      pump - the pump that has been replaced
    • replaceLine

      public void replaceLine(Holder holder)
      Notify listeners that the line associated with the holder has been replaced.
      Parameters:
      holder - the holder with the line that was replaced