public final class

LockFreeEventPublisher

extends Object
implements EventPublisher
java.lang.Object
   ↳ com.atlassian.event.internal.LockFreeEventPublisher

Class Overview

A non-blocking implementation of the EventPublisher interface.

This class is a drop-in replacement for EventPublisherImpl except that it does not synchronise on the internal map of event type to ListenerInvoker, and should handle much higher parallelism of event dispatch.

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.

Summary

Public Constructors
LockFreeEventPublisher(EventDispatcher eventDispatcher, ListenerHandlersConfiguration listenerHandlersConfiguration)
If you need to customise the asynchronous handling, you should use the AsynchronousAbleEventDispatcher together with a custom executor.
Public Methods
void publish(Object event)
Publish an event that will be consumed by all listeners which have registered to receive it.
void register(Object listener)
Register a listener to receive events.
void unregister(Object listener)
Un-register a listener so that it will no longer receive events.
void unregisterAll()
Un-register all listeners that this publisher knows about.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.event.api.EventPublisher

Public Constructors

public LockFreeEventPublisher (EventDispatcher eventDispatcher, ListenerHandlersConfiguration listenerHandlersConfiguration)

If you need to customise the asynchronous handling, you should use the AsynchronousAbleEventDispatcher together with a custom executor.

You might also want to have a look at using the EventThreadFactory to 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 publisher
listenerHandlersConfiguration the list of listener handlers to be used with this publisher

Public Methods

public void publish (Object event)

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). Implementations may also dispatch events to legacy EventListener implementations based on the types returned from getHandledEventClasses(). This method should process all event listeners, despite any errors or exceptions that are generated as a result of dispatching the event.

Parameters
event the event to publish

public void register (Object listener)

Register a listener to receive events. All implementations must support registration of listeners where event handling methods are indicated by the EventListener annotation. Legacy implementations may also support listeners which implement the now-deprecated EventListener interface.

Parameters
listener The listener that is being registered

public void unregister (Object listener)

Un-register a listener so that it will no longer receive events. If the given listener is not registered nothing will happen.

Parameters
listener The listener to un-register

public void unregisterAll ()

Un-register all listeners that this publisher knows about.