Package org.onosproject.event
Class ListenerTracker
- java.lang.Object
-
- org.onosproject.event.ListenerTracker
-
@Beta @NotThreadSafe public class ListenerTracker extends Object
Utility to keeps track of registered Listeners.Usage Example:
private ListenerTracker listeners;
@Activate
protected void activate() { listeners = new ListenerTracker(); listeners.addListener(mastershipService, new InternalMastershipListener()) .addListener(deviceService, new InternalDeviceListener()) .addListener(linkService, new InternalLinkListener()) .addListener(topologyService, new InternalTopologyListener()) .addListener(hostService, new InternalHostListener()); }@Deactivate
protected void deactivate() { listeners.removeListeners(); }
-
-
Constructor Summary
Constructors Constructor Description ListenerTracker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <E extends Event<?,?>,L extends EventListener<E>>
ListenerTrackeraddListener(ListenerService<E,L> service, L listener)
AddsEventListener
to specifiedListenerService
.void
removeListeners()
Removes all listeners in reverse order they have been registered.
-
-
-
Method Detail
-
addListener
public <E extends Event<?,?>,L extends EventListener<E>> ListenerTracker addListener(ListenerService<E,L> service, L listener)
AddsEventListener
to specifiedListenerService
.- Type Parameters:
E
- eventL
- listener- Parameters:
service
-ListenerService
listener
-EventListener
- Returns:
- self
-
removeListeners
public void removeListeners()
Removes all listeners in reverse order they have been registered.
-
-