Class EventPublisherImpl

java.lang.Object
com.atlassian.event.internal.EventPublisherImpl
All Implemented Interfaces:
EventListenerRegistrar, EventPublisher

@ThreadSafe public final class EventPublisherImpl extends Object implements EventPublisher
The default implementation of the EventPublisher interface.

One can customise the event listening by instantiating with custom listener handlers and the event dispatching through EventDispatcher.

See the com.atlassian.event.spi package for more information.

Since:
2.0
See Also:
  • Constructor Details

  • Method Details

    • publish

      public void publish(@Nonnull Object event)
      Description copied from interface: EventPublisher
      Publish an event that will be consumed by all listeners which have registered to receive it. Implementations must dispatch events to listeners which have a public method annotated with EventListener and one argument which is assignable from the event type (i.e. a superclass or interface implemented by the event object). This method should process all event listeners, despite any errors or exceptions that are generated as a result of dispatching the event.

      Default order

      The order in which registered listeners are invoked is predictable. Listeners will be invoked for listeners registered on the object itself, then listeners on the parent class, then the grandparent and so on until finally all listeners for java.lang.Object are invoked.

      After walking the class hierarchy the interface listeners are invoked, again from the most specific interface first. Note that the ordering within a specific event type is not guaranteed. If there are multiple registered listeners for IssueEvent, then they will be invoked in the order of registration. It is however guaranteed that a listener for IssueEvent will be invoked before a listener for Event

      Custom order

      The default order can be overridden with EventListener.order(). Event listeners with order defined are overriding default rules and will be processed in ascending order of the EventListener.order() value. Default ordering is preserved when processing event listeners with the same EventListener.order() value. There is a soft rule for plugin event listeners to use order values in range [-1000, 1000] if needed. Values in following ranges: [Integer.MIN_VALUE, -1000) and (1000, Integer.MAX_VALUE] are reserved for Atlassian product internal event listeners.
      Specified by:
      publish in interface EventPublisher
      Parameters:
      event - the event to publish
    • register

      public void register(@Nonnull Object listener)
      Description copied from interface: EventListenerRegistrar
      Register a listener to receive events.

      All implementations must support registration of listeners where event handling methods are indicated by the EventListener annotation.

      Specified by:
      register in interface EventListenerRegistrar
      Parameters:
      listener - The listener that is being registered
      See Also:
    • unregister

      public void unregister(@Nonnull Object listener)
      Description copied from interface: EventListenerRegistrar
      Un-register a listener so that it will no longer receive events.

      If the given listener is not registered, nothing will happen.

      Specified by:
      unregister in interface EventListenerRegistrar
      Parameters:
      listener - The listener to un-register
    • unregisterAll

      public void unregisterAll()
      Description copied from interface: EventListenerRegistrar
      Un-register all listeners that this registrar knows about.
      Specified by:
      unregisterAll in interface EventListenerRegistrar