com.atlassian.event.internal
Class EventPublisherImpl

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

public class EventPublisherImpl
extends java.lang.Object
implements EventPublisher, EventManager

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, java.util.List<ListenerHandler> listenerHandlers)
          This constructor lets you customise your event dispatcher.
EventPublisherImpl(java.util.List<ListenerHandler> listenerHandlers)
          This constructor manages synchronous and asynchronous events through the use of the AsynchronousAbleEventDispatcher.
 
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 publishEvent(Event 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 registerListener(java.lang.String listenerKey, EventListener 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 unregisterListener(java.lang.String listenerKey)
          Un-register a listener so that it will no longer receive events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventPublisherImpl

public EventPublisherImpl(java.util.List<ListenerHandler> listenerHandlers)

This constructor manages synchronous and asynchronous events through the use of the AsynchronousAbleEventDispatcher. This is used together with a ThreadPoolExecutor and a EventThreadFactory

The default values for the thread pool executor are:

Parameters:
listenerHandlers - the list of listener handlers to be used with this publisher
See Also:
if you need to customise the {@link com.atlassian.event.spi.EventDispatcher}, AsynchronousAbleEventDispatcher, ThreadPoolExecutor, EventThreadFactory

EventPublisherImpl

public EventPublisherImpl(EventDispatcher eventDispatcher,
                          java.util.List<ListenerHandler> listenerHandlers)

This constructor lets you customise your event dispatcher. It is highly recommended to use the other constructor.

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
listenerHandlers - the list of listener handlers to be used with this publisher
See Also:
EventPublisherImpl(java.util.List), AsynchronousAbleEventDispatcher, EventThreadFactory
Method Detail

publish

public void publish(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.

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

register

public void register(java.lang.Object listener)
Description copied from interface: EventPublisher
Register a listener to receive events.

Specified by:
register in interface EventPublisher
Parameters:
listener - The listener that is being registered

unRegister

public void unRegister(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

publishEvent

public void publishEvent(Event event)
Description copied from interface: EventManager
Publish an event that will be consumed by all listeners which have registered to receive it.

Specified by:
publishEvent in interface EventManager
Parameters:
event - the event to publish

registerListener

public void registerListener(java.lang.String listenerKey,
                             EventListener listener)
Description copied from interface: EventManager
Register a listener to receive events. If you register a listener with the same key as an existing listener, the previous listener with that key will be unregistered.

Specified by:
registerListener in interface EventManager
Parameters:
listenerKey - A unique key for this listener. If the listener is a plugin module, use the module's complete key
listener - The listener that is being registered

unregisterListener

public void unregisterListener(java.lang.String listenerKey)
Description copied from interface: EventManager
Un-register a listener so that it will no longer receive events. If no listener is registered under this key, nothing will happen.

Specified by:
unregisterListener in interface EventManager
Parameters:
listenerKey - the key under which the listener was registered.


Copyright © 2006-2009 Atlassian. All Rights Reserved.