org.apache.hivemind.util
Class EventListenerList

java.lang.Object
  extended by org.apache.hivemind.util.EventListenerList

public class EventListenerList
extends java.lang.Object

Convienience class for tracking a list of event listeners. Works efficiently (using a copy-on-write approach) to iterating through the listeners in the list even when the list of listeners may be modified.

EventListenerList is thread-safe.

Author:
Howard Lewis Ship

Constructor Summary
EventListenerList()
           
 
Method Summary
 void addListener(java.lang.Object listener)
          Adds a new listener to the list of listeners.
 java.util.Iterator getListeners()
          Returns an Iterator used to find all the listeners previously added.
 void removeListener(java.lang.Object listener)
          Removes a listener from the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventListenerList

public EventListenerList()
Method Detail

getListeners

public java.util.Iterator getListeners()
Returns an Iterator used to find all the listeners previously added. The order in which listeners are returned is not guaranteed. Currently, you may not invoke remove() on the Iterator.

Invoking this method takes a "snapshot" of the current list of listeners. You may invoke addListener(Object) or removeListener(Object), but that won't affect the sequence of listeners returned by the Iterator.


addListener

public void addListener(java.lang.Object listener)
Adds a new listener to the list of listeners. The same instance will may be added multiple times.


removeListener

public void removeListener(java.lang.Object listener)
Removes a listener from the list. Does nothing if the listener is not already in the list. Comparison is based on identity, not equality. If the listener is in the list multiple times, only a single instance is removed.