com.atlassian.event.internal
Class EventPublisherImpl

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

public final class EventPublisherImpl
extends java.lang.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:
ListenerHandler, EventDispatcher

Constructor Summary
EventPublisherImpl(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)
          The order in which registered listeners are invoked is predictable.
 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 registrar knows about.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventPublisherImpl

public EventPublisherImpl(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(java.lang.Object event)
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

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

register

public void register(java.lang.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. Legacy implementations may also support listeners which implement the now-deprecated EventListener interface.

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

unregister

public void unregister(java.lang.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


Copyright © 2006-2013 Atlassian. All Rights Reserved.