Class AbstractEventSource<E,L extends EventListener<?>>

java.lang.Object
io.github.mmm.event.AbstractEventSource<E,L>
Type Parameters:
E - the type of the events to send.
L - the type of the listeners.
All Implemented Interfaces:
EventSource<E,L>
Direct Known Subclasses:
AbstractEventBus.EventDispatcher, AbstractEventSender

public abstract class AbstractEventSource<E,L extends EventListener<?>> extends Object implements EventSource<E,L>
Implementation of EventSource.
Since:
1.0.0
  • Constructor Details

    • AbstractEventSource

      public AbstractEventSource()
      The constructor.
  • Method Details

    • addListener

      public void addListener(L listener, boolean weak)
      Description copied from interface: EventSource
      Adds an EventListener which will be notified whenever the an event occurs (something changes). If the same listener is added more than once, it will be notified more than once. The same EventListener instance may be registered for different EventSources.
      Specified by:
      addListener in interface EventSource<E,L extends EventListener<?>>
      Parameters:
      listener - the EventListener to register.
      weak - - true if the EventListener may be garbage collected without being removed via a WeakReference, false otherwise (if the listener will be associated using a strong reference). When providing true here (use WeakReference), you need to store a reference to your registered EventListener yourself in the owning parent object so it is not garbage-collected too early.
      See Also:
    • doAddListener

      protected abstract void doAddListener(EventListener<E> listener)
      Parameters:
      listener - the EventListener to add.
    • fireEvent

      protected abstract boolean fireEvent(E event)
      Parameters:
      event - the event to send to all registered EventListeners.
      Returns:
      true if the event has actually been dispatched, false otherwise (no listener was registered for the event).