View Javadoc

1   package com.atlassian.event;
2   
3   /**
4    * Interface to manage events. It essentially allows to register event listeners and publish events.
5    *
6    * @since 1.0
7    * @deprecated since 2.0, use {@link com.atlassian.event.api.EventPublisher}
8    */
9   public interface EventManager {
10      /**
11       * Publish an event that will be consumed by all listeners which have registered to receive it.
12       *
13       * @param event the event to publish
14       * @throws NullPointerException if the event is {@code null}
15       */
16      void publishEvent(Event event);
17  
18      /**
19       * Register a listener to receive events. If you register a listener with the same key as an existing listener,
20       * the previous listener with that key will be unregistered.
21       *
22       * @param listenerKey A unique key for this listener. If the listener is a plugin module, use the
23       *                    module's complete key
24       * @param listener    The listener that is being registered
25       * @throws NullPointerException     if the listenerKey or listener is {@code null}
26       * @throws IllegalArgumentException if the listener key is empty (i.e. {@code null} or empty {@link String})
27       */
28      void registerListener(String listenerKey, EventListener listener);
29  
30      /**
31       * Un-register a listener so that it will no longer receive events. If no listener is registered under this key,
32       * nothing will happen.
33       *
34       * @param listenerKey the key under which the listener was registered.
35       * @throws IllegalArgumentException if the listener key is empty (i.e. {@code null} or empty {@link String})
36       */
37      void unregisterListener(String listenerKey);
38  }