public class ListenerRegistry<Listener> extends Object
Details:
A ListenerRegistry
maintains a list of subscribed listeners that have expressed their interest in notifications for certain types of events.
ListenerRegistry
is designed to support classes that accept listener subscriptions, such as AWT and Swing components.
ListenerRegistry
is completely thread-
Constructor and Description |
---|
ListenerRegistry() |
Modifier and Type | Method and Description |
---|---|
Iterator<Listener> |
iterateListeners()
Iterates registered listeners.
|
void |
registerListener(Listener iListener)
Registers a listener.
|
void |
unregisterListener(Listener iListener)
Unregisters a listener.
|
public void registerListener(Listener iListener)
Details:
registerListener
registers the given listener to receive notifications from the owner of this registry.
A listener cannot be added twice.
No action is taken if the listener is already registered.
iListener
- the listener to registerpublic void unregisterListener(Listener iListener)
Details:
unregisterListener
unregisters the given listener so that it no longer receives messages from the registry owner.
No action is taken if the listener is not registered.
Listeners should unregister themselves when they no longer need to receive messages.
iListener
- the listener to unregisterpublic Iterator<Listener> iterateListeners()
Details:
iterateListeners
returns an Iterator
that walks through the list of all listeners that were registered at the moment this method was invoked.
(The Iterator
is based on a "snapshot" of this registry.)
Since the returned Iterator
exists independently from the internally stored listener list, elements may be added or removed from this registery while the iterator is still in use.
Copyright © 2013. All Rights Reserved.