Adding some base-classes to eliminate event and listener boiler-plate code throughout a number of subsystems.

Refactored all core components to take advantage of this; apps remain to be done.

Change-Id: Ib0935ba07ff81b0fa032534004ec9ac6187cbf22
diff --git a/core/api/src/main/java/org/onosproject/app/ApplicationService.java b/core/api/src/main/java/org/onosproject/app/ApplicationService.java
index 1aaf092..bb55da9 100644
--- a/core/api/src/main/java/org/onosproject/app/ApplicationService.java
+++ b/core/api/src/main/java/org/onosproject/app/ApplicationService.java
@@ -18,13 +18,15 @@
 import org.onosproject.core.Application;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.Permission;
+import org.onosproject.event.ListenerService;
 
 import java.util.Set;
 
 /**
  * Service for inspecting inventory of network control applications.
  */
-public interface ApplicationService {
+public interface ApplicationService
+        extends ListenerService<ApplicationEvent, ApplicationListener> {
 
     /**
      * Returns the set of all installed applications.
@@ -65,18 +67,4 @@
      */
     Set<Permission> getPermissions(ApplicationId appId);
 
-    /**
-     * Adds the given listener for application lifecycle events.
-     *
-     * @param listener listener to be added
-     */
-    void addListener(ApplicationListener listener);
-
-    /**
-     * Removes the specified listener for application lifecycle events.
-     *
-     * @param listener listener to be removed
-     */
-    void removeListener(ApplicationListener listener);
-
 }
diff --git a/core/api/src/main/java/org/onosproject/cluster/ClusterService.java b/core/api/src/main/java/org/onosproject/cluster/ClusterService.java
index e708588..015a648 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ClusterService.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ClusterService.java
@@ -18,12 +18,14 @@
 import java.util.Set;
 
 import org.joda.time.DateTime;
+import org.onosproject.event.ListenerService;
 
 /**
  * Service for obtaining information about the individual nodes within
  * the controller cluster.
  */
-public interface ClusterService {
+public interface ClusterService
+    extends ListenerService<ClusterEvent, ClusterEventListener> {
 
     /**
      * Returns the local controller node.
@@ -63,18 +65,4 @@
      */
     DateTime getLastUpdated(NodeId nodeId);
 
-    /**
-     * Adds the specified cluster event listener.
-     *
-     * @param listener the cluster listener
-     */
-    void addListener(ClusterEventListener listener);
-
-    /**
-     * Removes the specified cluster event listener.
-     *
-     * @param listener the cluster listener
-     */
-    void removeListener(ClusterEventListener listener);
-
 }
diff --git a/core/api/src/main/java/org/onosproject/cluster/LeadershipService.java b/core/api/src/main/java/org/onosproject/cluster/LeadershipService.java
index 9130f4f..7d1f607 100644
--- a/core/api/src/main/java/org/onosproject/cluster/LeadershipService.java
+++ b/core/api/src/main/java/org/onosproject/cluster/LeadershipService.java
@@ -15,6 +15,8 @@
  */
 package org.onosproject.cluster;
 
+import org.onosproject.event.ListenerService;
+
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -27,7 +29,8 @@
  * Listeners can be added to receive notifications asynchronously for various
  * leadership contests.
  */
-public interface LeadershipService {
+public interface LeadershipService
+    extends ListenerService<LeadershipEvent, LeadershipEventListener> {
 
     /**
      * Returns the current leader for the topic.
@@ -118,17 +121,4 @@
      */
     List<NodeId> getCandidates(String path);
 
-    /**
-     * Registers a event listener to be notified of leadership events.
-     *
-     * @param listener listener that will asynchronously notified of leadership events.
-     */
-    void addListener(LeadershipEventListener listener);
-
-    /**
-     * Unregisters a event listener for leadership events.
-     *
-     * @param listener listener to be removed.
-     */
-    void removeListener(LeadershipEventListener listener);
 }
diff --git a/core/api/src/main/java/org/onosproject/event/AbstractListenerManager.java b/core/api/src/main/java/org/onosproject/event/AbstractListenerManager.java
new file mode 100644
index 0000000..cbe7421
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/event/AbstractListenerManager.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.event;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+
+/**
+ * Basis for components which need to export listener mechanism.
+ */
+@Component(componentAbstract = true)
+public abstract class AbstractListenerManager<E extends Event, L extends EventListener<E>>
+    implements ListenerService<E, L> {
+
+    protected final ListenerRegistry<E, L> listenerRegistry = new ListenerRegistry<>();
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected EventDeliveryService eventDispatcher;
+
+    @Override
+    public void addListener(L listener) {
+        listenerRegistry.addListener(listener);
+    }
+
+    @Override
+    public void removeListener(L listener) {
+        listenerRegistry.removeListener(listener);
+    }
+
+
+    /**
+     * Safely posts the specified event to the local event dispatcher.
+     * If there is no event dispatcher or if the event is null, this method
+     * is a noop.
+     *
+     * @param event event to be posted; may be null
+     */
+    protected void post(E event) {
+        if (event != null && eventDispatcher != null) {
+            eventDispatcher.post(event);
+        }
+    }
+
+}
diff --git a/core/api/src/main/java/org/onosproject/event/ListenerRegistry.java b/core/api/src/main/java/org/onosproject/event/ListenerRegistry.java
index e6af201..ef02af06 100644
--- a/core/api/src/main/java/org/onosproject/event/ListenerRegistry.java
+++ b/core/api/src/main/java/org/onosproject/event/ListenerRegistry.java
@@ -28,7 +28,7 @@
  * listeners and dispatching events to them as part of event sink processing.
  */
 public class ListenerRegistry<E extends Event, L extends EventListener<E>>
-        implements EventSink<E> {
+        implements ListenerService<E, L>, EventSink<E> {
 
     private static final long LIMIT = 1_800; // ms
 
@@ -42,22 +42,13 @@
      */
     protected final Set<L> listeners = new CopyOnWriteArraySet<>();
 
-
-    /**
-     * Adds the specified listener.
-     *
-     * @param listener listener to be added
-     */
+    @Override
     public void addListener(L listener) {
         checkNotNull(listener, "Listener cannot be null");
         listeners.add(listener);
     }
 
-    /**
-     * Removes the specified listener.
-     *
-     * @param listener listener to be removed
-     */
+    @Override
     public void removeListener(L listener) {
         checkNotNull(listener, "Listener cannot be null");
         if (!listeners.remove(listener)) {
diff --git a/core/api/src/main/java/org/onosproject/event/ListenerService.java b/core/api/src/main/java/org/onosproject/event/ListenerService.java
new file mode 100644
index 0000000..a4a3631
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/event/ListenerService.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.event;
+
+/**
+ * Abstraction of a service capable of asynchronously notifying listeners.
+ */
+public interface ListenerService<E extends Event, L extends EventListener<E>> {
+
+    /**
+     * Adds the specified listener.
+     *
+     * @param listener listener to be added
+     */
+    void addListener(L listener);
+
+    /**
+     * Removes the specified listener.
+     *
+     * @param listener listener to be removed
+     */
+    void removeListener(L listener);
+
+
+}
diff --git a/core/api/src/main/java/org/onosproject/mastership/MastershipService.java b/core/api/src/main/java/org/onosproject/mastership/MastershipService.java
index 79eef94..75d0eac 100644
--- a/core/api/src/main/java/org/onosproject/mastership/MastershipService.java
+++ b/core/api/src/main/java/org/onosproject/mastership/MastershipService.java
@@ -20,6 +20,7 @@
 
 import org.onosproject.cluster.NodeId;
 import org.onosproject.cluster.RoleInfo;
+import org.onosproject.event.ListenerService;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.MastershipRole;
 
@@ -29,7 +30,8 @@
  * determining mastership, but is not responsible for actually applying it
  * to the devices; this falls on the device service.
  */
-public interface MastershipService {
+public interface MastershipService
+    extends ListenerService<MastershipEvent, MastershipListener> {
 
     /**
      * Returns the role of the local node for the specified device, without
@@ -84,18 +86,4 @@
      */
     Set<DeviceId> getDevicesOf(NodeId nodeId);
 
-    /**
-     * Adds the specified mastership change listener.
-     *
-     * @param listener the mastership listener
-     */
-    void addListener(MastershipListener listener);
-
-    /**
-     * Removes the specified mastership change listener.
-     *
-     * @param listener the mastership listener
-     */
-    void removeListener(MastershipListener listener);
-
 }
diff --git a/core/api/src/main/java/org/onosproject/net/device/DeviceService.java b/core/api/src/main/java/org/onosproject/net/device/DeviceService.java
index ab6dba5..c59454d 100644
--- a/core/api/src/main/java/org/onosproject/net/device/DeviceService.java
+++ b/core/api/src/main/java/org/onosproject/net/device/DeviceService.java
@@ -15,6 +15,7 @@
  */
 package org.onosproject.net.device;
 
+import org.onosproject.event.ListenerService;
 import org.onosproject.net.Device;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.MastershipRole;
@@ -26,7 +27,8 @@
 /**
  * Service for interacting with the inventory of infrastructure devices.
  */
-public interface DeviceService {
+public interface DeviceService
+    extends ListenerService<DeviceEvent, DeviceListener> {
 
     /**
      * Returns the number of infrastructure devices known to the system.
@@ -119,18 +121,4 @@
      */
     boolean isAvailable(DeviceId deviceId);
 
-    /**
-     * Adds the specified device listener.
-     *
-     * @param listener device listener
-     */
-    void addListener(DeviceListener listener);
-
-    /**
-     * Removes the specified device listener.
-     *
-     * @param listener device listener
-     */
-    void removeListener(DeviceListener listener);
-
 }
diff --git a/core/api/src/main/java/org/onosproject/net/edge/EdgePortService.java b/core/api/src/main/java/org/onosproject/net/edge/EdgePortService.java
index c91018e..89a2c17 100644
--- a/core/api/src/main/java/org/onosproject/net/edge/EdgePortService.java
+++ b/core/api/src/main/java/org/onosproject/net/edge/EdgePortService.java
@@ -15,6 +15,7 @@
  */
 package org.onosproject.net.edge;
 
+import org.onosproject.event.ListenerService;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.flow.TrafficTreatment;
@@ -27,7 +28,8 @@
  * is considered an edge port if it is an active port and does not have an
  * infrastructure link associated with it.
  */
-public interface EdgePortService {
+public interface EdgePortService
+        extends ListenerService<EdgePortEvent, EdgePortListener> {
 
     /**
      * Indicates whether or not the specified connection point is an edge point.
@@ -70,18 +72,4 @@
     void emitPacket(DeviceId deviceId, ByteBuffer data,
                     Optional<TrafficTreatment> treatment);
 
-    /**
-     * Adds a listener for edge port events.
-     *
-     * @param listener listener to be added
-     */
-    void addListener(EdgePortListener listener);
-
-    /**
-     * Removes the listener for edge port events.
-     *
-     * @param listener listener to be removed
-     */
-    void removeListener(EdgePortListener listener);
-
 }
diff --git a/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java b/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java
index 43d0f5d..e297115 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java
@@ -16,6 +16,7 @@
 package org.onosproject.net.flow;
 
 import org.onosproject.core.ApplicationId;
+import org.onosproject.event.ListenerService;
 import org.onosproject.net.DeviceId;
 
 /**
@@ -25,7 +26,8 @@
  * of the flow rules lies with the controller and the devices hold only the
  * 'cached' copy.
  */
-public interface FlowRuleService {
+public interface FlowRuleService
+    extends ListenerService<FlowRuleEvent, FlowRuleListener> {
 
     /**
      * The topic used for obtaining globally unique ids.
@@ -102,17 +104,4 @@
      */
     void apply(FlowRuleOperations ops);
 
-    /**
-     * Adds the specified flow rule listener.
-     *
-     * @param listener flow rule listener
-     */
-    void addListener(FlowRuleListener listener);
-
-    /**
-     * Removes the specified flow rule listener.
-     *
-     * @param listener flow rule listener
-     */
-    void removeListener(FlowRuleListener listener);
 }
diff --git a/core/api/src/main/java/org/onosproject/net/group/GroupService.java b/core/api/src/main/java/org/onosproject/net/group/GroupService.java
index cdd56c7..4163248 100644
--- a/core/api/src/main/java/org/onosproject/net/group/GroupService.java
+++ b/core/api/src/main/java/org/onosproject/net/group/GroupService.java
@@ -16,6 +16,7 @@
 package org.onosproject.net.group;
 
 import org.onosproject.core.ApplicationId;
+import org.onosproject.event.ListenerService;
 import org.onosproject.net.DeviceId;
 
 /**
@@ -32,7 +33,8 @@
  * where the master copy of the groups lies with the controller and
  * the devices hold only the 'cached' copy.
  */
-public interface GroupService {
+public interface GroupService
+    extends ListenerService<GroupEvent, GroupListener> {
 
     /**
      * Creates a group in the specified device with the provided buckets.
@@ -134,17 +136,4 @@
      */
     Iterable<Group> getGroups(DeviceId deviceId);
 
-    /**
-     * Adds the specified group listener.
-     *
-     * @param listener group listener
-     */
-    void addListener(GroupListener listener);
-
-    /**
-     * Removes the specified group listener.
-     *
-     * @param listener group listener
-     */
-    void removeListener(GroupListener listener);
 }
diff --git a/core/api/src/main/java/org/onosproject/net/host/HostService.java b/core/api/src/main/java/org/onosproject/net/host/HostService.java
index 6fa52ce..a2a8291 100644
--- a/core/api/src/main/java/org/onosproject/net/host/HostService.java
+++ b/core/api/src/main/java/org/onosproject/net/host/HostService.java
@@ -17,6 +17,7 @@
 
 import java.util.Set;
 
+import org.onosproject.event.ListenerService;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.Host;
@@ -28,7 +29,8 @@
 /**
  * Service for interacting with the inventory of end-station hosts.
  */
-public interface HostService {
+public interface HostService
+    extends ListenerService<HostEvent, HostListener> {
 
     /**
      * Returns the number of end-station hosts known to the system.
@@ -137,18 +139,4 @@
      */
     Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint);
 
-    /**
-     * Adds the specified host listener.
-     *
-     * @param listener host listener
-     */
-    void addListener(HostListener listener);
-
-    /**
-     * Removes the specified host listener.
-     *
-     * @param listener host listener
-     */
-    void removeListener(HostListener listener);
-
 }
diff --git a/core/api/src/main/java/org/onosproject/net/intent/IntentService.java b/core/api/src/main/java/org/onosproject/net/intent/IntentService.java
index ccc97d8..8533ceb 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/IntentService.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/IntentService.java
@@ -17,6 +17,7 @@
 
 
 import com.google.common.annotations.Beta;
+import org.onosproject.event.ListenerService;
 
 import java.util.List;
 
@@ -24,7 +25,9 @@
  * Service for application submitting or withdrawing their intents.
  */
 @Beta
-public interface IntentService {
+public interface IntentService
+    extends ListenerService<IntentEvent, IntentListener> {
+
     /**
      * Submits an intent into the system.
      * <p>
@@ -117,17 +120,4 @@
      */
     Iterable<Intent> getPending();
 
-    /**
-     * Adds the specified listener for intent events.
-     *
-     * @param listener listener to be added
-     */
-    void addListener(IntentListener listener);
-
-    /**
-     * Removes the specified listener for intent events.
-     *
-     * @param listener listener to be removed
-     */
-    void removeListener(IntentListener listener);
 }
diff --git a/core/api/src/main/java/org/onosproject/net/intent/PartitionService.java b/core/api/src/main/java/org/onosproject/net/intent/PartitionService.java
index 7c9d547..02cccca 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/PartitionService.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/PartitionService.java
@@ -17,12 +17,14 @@
 
 import com.google.common.annotations.Beta;
 import org.onosproject.cluster.NodeId;
+import org.onosproject.event.ListenerService;
 
 /**
  * Service for interacting with the partition-to-instance assignments.
  */
 @Beta
-public interface PartitionService {
+public interface PartitionService
+    extends ListenerService<PartitionEvent, PartitionEventListener> {
 
     /**
      * Returns whether the given intent key is in a partition owned by this
@@ -43,17 +45,4 @@
 
     // TODO add API for rebalancing partitions
 
-    /**
-     * Registers a event listener to be notified of partition events.
-     *
-     * @param listener listener that will asynchronously notified of partition events.
-     */
-    void addListener(PartitionEventListener listener);
-
-    /**
-     * Unregisters a event listener for partition events.
-     *
-     * @param listener listener to be removed.
-     */
-    void removeListener(PartitionEventListener listener);
 }
diff --git a/core/api/src/main/java/org/onosproject/net/link/LinkService.java b/core/api/src/main/java/org/onosproject/net/link/LinkService.java
index 5cae77b..c27e311 100644
--- a/core/api/src/main/java/org/onosproject/net/link/LinkService.java
+++ b/core/api/src/main/java/org/onosproject/net/link/LinkService.java
@@ -17,6 +17,7 @@
 
 import java.util.Set;
 
+import org.onosproject.event.ListenerService;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.Link;
@@ -24,7 +25,8 @@
 /**
  * Service for interacting with the inventory of infrastructure links.
  */
-public interface LinkService {
+public interface LinkService
+    extends ListenerService<LinkEvent, LinkListener> {
 
     /**
      * Returns the count of all known infrastructure links.
@@ -111,18 +113,4 @@
      */
     Link getLink(ConnectPoint src, ConnectPoint dst);
 
-    /**
-     * Adds the specified link listener.
-     *
-     * @param listener link listener
-     */
-    void addListener(LinkListener listener);
-
-    /**
-     * Removes the specified link listener.
-     *
-     * @param listener link listener
-     */
-    void removeListener(LinkListener listener);
-
 }
diff --git a/core/api/src/main/java/org/onosproject/net/provider/AbstractListenerProviderRegistry.java b/core/api/src/main/java/org/onosproject/net/provider/AbstractListenerProviderRegistry.java
new file mode 100644
index 0000000..ff67c6d
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/provider/AbstractListenerProviderRegistry.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.provider;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onosproject.event.Event;
+import org.onosproject.event.EventDeliveryService;
+import org.onosproject.event.EventListener;
+import org.onosproject.event.ListenerRegistry;
+import org.onosproject.event.ListenerService;
+
+/**
+ * Basis for components which need to export listener mechanism.
+ */
+@Component(componentAbstract = true)
+public abstract class AbstractListenerProviderRegistry<E extends Event, L extends EventListener<E>,
+                                                       P extends Provider, S extends ProviderService<P>>
+        extends AbstractProviderRegistry<P, S> implements ListenerService<E, L> {
+
+    // If only Java supported mixins...
+
+    protected final ListenerRegistry<E, L> listenerRegistry = new ListenerRegistry<>();
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected EventDeliveryService eventDispatcher;
+
+    @Override
+    public void addListener(L listener) {
+        listenerRegistry.addListener(listener);
+    }
+
+    @Override
+    public void removeListener(L listener) {
+        listenerRegistry.removeListener(listener);
+    }
+
+
+    /**
+     * Safely posts the specified event to the local event dispatcher.
+     * If there is no event dispatcher or if the event is null, this method
+     * is a noop.
+     *
+     * @param event event to be posted; may be null
+     */
+    protected void post(E event) {
+        if (event != null && eventDispatcher != null) {
+            eventDispatcher.post(event);
+        }
+    }
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceService.java b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceService.java
index 69bdf4f..6dc04df 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceService.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/link/LinkResourceService.java
@@ -15,6 +15,7 @@
  */
 package org.onosproject.net.resource.link;
 
+import org.onosproject.event.ListenerService;
 import org.onosproject.net.Link;
 import org.onosproject.net.intent.IntentId;
 import org.onosproject.net.resource.ResourceRequest;
@@ -22,7 +23,8 @@
 /**
  * Service for providing link resource allocation.
  */
-public interface LinkResourceService {
+public interface LinkResourceService
+    extends ListenerService<LinkResourceEvent, LinkResourceListener> {
 
     /**
      * Requests resources.
@@ -88,20 +90,6 @@
      * @return available resources for the target link
      */
     Iterable<ResourceRequest> getAvailableResources(Link link,
-                                          LinkResourceAllocations allocations);
-
-    /**
-     * Adds a listener for resource related events.
-     *
-     * @param listener listener to add
-     */
-    void addListener(LinkResourceListener listener);
-
-    /**
-     * Removes a listener for resource related events.
-     *
-     * @param listener listener to remove.
-     */
-    void removeListener(LinkResourceListener listener);
+                                                    LinkResourceAllocations allocations);
 
 }
diff --git a/core/api/src/main/java/org/onosproject/net/topology/TopologyService.java b/core/api/src/main/java/org/onosproject/net/topology/TopologyService.java
index b17deb3..41eac2c 100644
--- a/core/api/src/main/java/org/onosproject/net/topology/TopologyService.java
+++ b/core/api/src/main/java/org/onosproject/net/topology/TopologyService.java
@@ -15,6 +15,7 @@
  */
 package org.onosproject.net.topology;
 
+import org.onosproject.event.ListenerService;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.Link;
@@ -25,7 +26,8 @@
 /**
  * Service for providing network topology information.
  */
-public interface TopologyService {
+public interface TopologyService
+    extends ListenerService<TopologyEvent, TopologyListener> {
 
     /**
      * Returns the current topology descriptor.
@@ -130,18 +132,4 @@
      */
     boolean isBroadcastPoint(Topology topology, ConnectPoint connectPoint);
 
-    /**
-     * Adds the specified topology listener.
-     *
-     * @param listener topology listener
-     */
-    void addListener(TopologyListener listener);
-
-    /**
-     * Removes the specified topology listener.
-     *
-     * @param listener topology listener
-     */
-    void removeListener(TopologyListener listener);
-
 }