com.atlassian.event.api
Interface EventPublisher

All Known Implementing Classes:
EventPublisherImpl, LockFreeEventPublisher

public interface EventPublisher

Interface to publish events. It allows the decoupling of listeners which handle events and publishers which dispatch events.

Since:
2.0
See Also:
annotation which can be used to indicate event listener methods

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.
 

Method Detail

publish

void publish(java.lang.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 EventListener.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
Throws:
java.lang.NullPointerException - if the event is null

register

void register(java.lang.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
Throws:
java.lang.NullPointerException - if the listener is null
java.lang.IllegalArgumentException - if the parameter is not found to be an actual listener
See Also:
annotation which can be used to indicate event listener methods

unregister

void unregister(java.lang.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
Throws:
java.lang.NullPointerException - if the listener is null

unregisterAll

void unregisterAll()
Un-register all listeners that this publisher knows about.



Copyright © 2006-2010 Atlassian. All Rights Reserved.