Commits

Kenny MacLeod committed b4a5ce8

EVENT-17 - Extract registration methods of EventPublisher out into a separate interface

Comments (0)

Files changed (2)

src/main/java/com/atlassian/event/api/EventListenerRegistrar.java

+package com.atlassian.event.api;
+
+public interface EventListenerRegistrar
+{
+    /**
+     * Register a listener to receive events. All implementations must support registration of listeners
+     * where event handling methods are indicated by the {@link com.atlassian.event.api.EventListener} annotation. Legacy
+     * implementations may also support listeners which implement the now-deprecated
+     * {@link com.atlassian.event.EventListener} interface.
+     *
+     * @param listener The listener that is being registered
+     * @throws NullPointerException if the listener is {@code null}
+     * @throws IllegalArgumentException if the parameter is not found to be an actual listener
+     * @see com.atlassian.event.api.EventListener annotation which can be used to indicate event listener methods
+     */
+    void register(Object listener);
+
+    /**
+     * Un-register a listener so that it will no longer receive events. If the given listener is not registered nothing
+     * will happen.
+     * @param listener The listener to un-register
+     * @throws NullPointerException if the listener is {@code null}
+     */
+    void unregister(Object listener);
+
+    /**
+     * Un-register all listeners that this registrar knows about.
+     */
+    void unregisterAll();
+}

src/main/java/com/atlassian/event/api/EventPublisher.java

  * @since 2.0
  * @see EventListener annotation which can be used to indicate event listener methods
  */
-public interface EventPublisher
+public interface EventPublisher extends EventListenerRegistrar
 {
     /**
      * Publish an event that will be consumed by all listeners which have registered to receive it.
      * @throws NullPointerException if the event is {@code null}
      */
     void publish(Object event);
-
-    /**
-     * Register a listener to receive events. All implementations must support registration of listeners
-     * where event handling methods are indicated by the {@link EventListener} annotation. Legacy
-     * implementations may also support listeners which implement the now-deprecated
-     * {@link com.atlassian.event.EventListener} interface.
-     *
-     * @param listener The listener that is being registered
-     * @throws NullPointerException if the listener is {@code null}
-     * @throws IllegalArgumentException if the parameter is not found to be an actual listener
-     * @see EventListener annotation which can be used to indicate event listener methods
-     */
-    void register(Object listener);
-
-    /**
-     * Un-register a listener so that it will no longer receive events. If the given listener is not registered nothing
-     * will happen.
-     * @param listener The listener to un-register
-     * @throws NullPointerException if the listener is {@code null}
-     */
-    void unregister(Object listener);
-
-    /**
-     * Un-register all listeners that this publisher knows about.
-     */
-    void unregisterAll();
-}
+}