com.atlassian.event.internal
Class LockFreeEventPublisher

java.lang.Object
  extended by com.atlassian.event.internal.LockFreeEventPublisher
All Implemented Interfaces:
EventPublisher

public final class LockFreeEventPublisher
extends java.lang.Object
implements EventPublisher

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.

Since:
2.0.2
See Also:
ListenerHandler, EventDispatcher

Constructor Summary
LockFreeEventPublisher(EventDispatcher eventDispatcher, ListenerHandlersConfiguration listenerHandlersConfiguration)
          If you need to customise the asynchronous handling, you should use the AsynchronousAbleEventDispatcher together with a custom executor.
 
Method Summary
 void publish(java.lang.Object event)
          Publish an event that will be consumed by all listeners which have registered to receive it.
 void register(java.lang.Object listener)
          Register a listener to receive events.
 void unregister(java.lang.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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LockFreeEventPublisher

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
See Also:
AsynchronousAbleEventDispatcher, EventThreadFactory
Method Detail

publish

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

Specified by:
publish in interface EventPublisher
Parameters:
event - the event to publish

register

public void register(@NotNull
                     java.lang.Object listener)
Description copied from interface: EventPublisher
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.

Specified by:
register in interface EventPublisher
Parameters:
listener - The listener that is being registered
See Also:
annotation which can be used to indicate event listener methods

unregister

public void unregister(@NotNull
                       java.lang.Object listener)
Description copied from interface: EventPublisher
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 EventPublisher
Parameters:
listener - The listener to un-register

unregisterAll

public void unregisterAll()
Description copied from interface: EventPublisher
Un-register all listeners that this publisher knows about.

Specified by:
unregisterAll in interface EventPublisher


Copyright © 2006-2012 Atlassian. All Rights Reserved.