Class AbstractEventSupport<E extends EventListener>

  • All Implemented Interfaces:
    Externalizable, Serializable
    Direct Known Subclasses:
    AgendaEventSupport, RuleEventListenerSupport, RuleRuntimeEventSupport

    public abstract class AbstractEventSupport<E extends EventListener>
    extends Object
    implements Externalizable
    Base class for Thread-safe Event Support in Drools. Note that subclasses wishing to access the listeners should do so via the getEventListenersIterator method. This will provide an Iterator accessing the current snapshot of the underlying list, freeing the subclasss of thread problems.

    Please note that for lists of small sizes, and few modifications, the CopyOnWriteArrayList provides best performance. If the list is modified more often, than a simple ArrayList with synchonized operations, and copying of the array for iteration is faster.

    See Also:
    Serialized Form
    • Constructor Detail

      • AbstractEventSupport

        public AbstractEventSupport()
    • Method Detail

      • notifyAllListeners

        public <O> void notifyAllListeners​(O event,
                                           BiConsumer<E,​O> consumer)
      • hasListeners

        protected boolean hasListeners()
      • addEventListener

        public final void addEventListener​(E listener)
        Adds the specified listener to the list of listeners. Note that this method needs to be synchonized because it performs two independent operations on the underlying list
        Parameters:
        listener - to add
      • removeEventListener

        public final void removeEventListener​(Class cls)
        Removes all event listeners of the specified class. Note that this method needs to be synchonized because it performs two independent operations on the underlying list
        Parameters:
        cls - class of listener to remove
      • removeEventListener

        public final void removeEventListener​(E listener)
      • getEventListeners

        public List<E> getEventListeners()
      • clear

        public void clear()