Class EventListenerList

  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.

Howard Lewis Ship

Constructor Summary
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


public EventListenerList()
Method Detail


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.


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.


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.