Class ListenerRegistry<E extends Event,​L extends EventListener<E>>

  • All Implemented Interfaces:
    EventSink<E>, ListenerService<E,​L>

    public class ListenerRegistry<E extends Event,​L extends EventListener<E>>
    extends java.lang.Object
    implements ListenerService<E,​L>, EventSink<E>
    Base implementation of an event sink and a registry capable of tracking listeners and dispatching events to them as part of event sink processing.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Set<L> listeners
      Set of listeners that have registered.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addListener​(L listener)
      Adds the specified listener.
      void onProcessLimit()
      Handles notification that event processing time limit has been exceeded.
      void process​(E event)
      Processes the specified event.
      void removeListener​(L listener)
      Removes the specified listener.
      protected void reportProblem​(E event, java.lang.Throwable error)
      Reports a problem encountered while processing an event.
      • Methods inherited from class java.lang.Object

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

      • listeners

        protected final java.util.Set<L extends EventListener<E>> listeners
        Set of listeners that have registered.
    • Constructor Detail

      • ListenerRegistry

        public ListenerRegistry()
    • Method Detail

      • process

        public void process​(E event)
        Description copied from interface: EventSink
        Processes the specified event.
        Specified by:
        process in interface EventSink<E extends Event>
        Parameters:
        event - event to be processed
      • onProcessLimit

        public void onProcessLimit()
        Description copied from interface: EventSink
        Handles notification that event processing time limit has been exceeded.
        Specified by:
        onProcessLimit in interface EventSink<E extends Event>
      • reportProblem

        protected void reportProblem​(E event,
                                     java.lang.Throwable error)
        Reports a problem encountered while processing an event.
        Parameters:
        event - event being processed
        error - error encountered while processing