Class EventPublisherImpl
- All Implemented Interfaces:
EventListenerRegistrar,EventPublisher
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 Summary
ConstructorsConstructorDescriptionEventPublisherImpl(EventDispatcher eventDispatcher, ListenerHandlersConfiguration configuration) EventPublisherImpl(EventDispatcher eventDispatcher, ListenerHandlersConfiguration listenerHandlersConfiguration, InvokerTransformer transformer) If you need to customise the asynchronous handling, you should use theAsynchronousAbleEventDispatchertogether with a custom executor. -
Method Summary
Modifier and TypeMethodDescriptionvoidPublish an event that will be consumed by all listeners which have registered to receive it.voidRegister a listener to receive events.voidunregister(Object listener) Un-register a listener so that it will no longer receive events.voidUn-register all listeners that this registrar knows about.
-
Constructor Details
-
EventPublisherImpl
public EventPublisherImpl(EventDispatcher eventDispatcher, ListenerHandlersConfiguration configuration) -
EventPublisherImpl
public EventPublisherImpl(EventDispatcher eventDispatcher, ListenerHandlersConfiguration listenerHandlersConfiguration, InvokerTransformer transformer) If you need to customise the asynchronous handling, you should use theAsynchronousAbleEventDispatchertogether with a custom executor.You might also want to have a look at using the
EventThreadFactoryto keep the naming of event threads consistent with the default naming of the Atlassian Event library.- Parameters:
eventDispatcher- the event dispatcher to be used with the publisherlistenerHandlersConfiguration- the list of listener handlers to be used with this publishertransformer- the batcher for batching up listener invocations- See Also:
-
-
Method Details
-
publish
Description copied from interface:EventPublisherPublish 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 withEventListenerand 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 withEventListener.order(). Event listeners with order defined are overriding default rules and will be processed in ascending order of theEventListener.order()value. Default ordering is preserved when processing event listeners with the sameEventListener.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:
publishin interfaceEventPublisher- Parameters:
event- the event to publish
-
register
Description copied from interface:EventListenerRegistrarRegister a listener to receive events.All implementations must support registration of listeners where event handling methods are indicated by the
EventListenerannotation.- Specified by:
registerin interfaceEventListenerRegistrar- Parameters:
listener- The listener that is being registered- See Also:
-
unregister
Description copied from interface:EventListenerRegistrarUn-register a listener so that it will no longer receive events.If the given listener is not registered, nothing will happen.
- Specified by:
unregisterin interfaceEventListenerRegistrar- Parameters:
listener- The listener to un-register
-
unregisterAll
public void unregisterAll()Description copied from interface:EventListenerRegistrarUn-register all listeners that this registrar knows about.- Specified by:
unregisterAllin interfaceEventListenerRegistrar
-