echopoint.event
Class WeakEventListenerList

java.lang.Object
  extended by nextapp.echo.event.EventListenerList
      extended by echopoint.event.WeakEventListenerList
All Implemented Interfaces:
java.io.Serializable

public class WeakEventListenerList
extends EventListenerList
implements java.io.Serializable

The WeakEventListenerList is basically the same as a nextapp.echo.EventListenerList except that it uses WeakReferences to the listeners.

It has the advantage that if a Model class (using this list class) has listeners which forget to remove themselves from the model then they will be automatically cleaned up by the Java Garbage Collector.

It has the disadvantage that if the listener is stand alone, ie. is not strongly reached by any other object, then it will be eligible for garbage collection and hence will disappear from the list.

See Also:
WeakReference, EventListenerList, Serialized Form

Constructor Summary
WeakEventListenerList()
          Creates a new WeakEventListenerList
 
Method Summary
 void addListener(java.lang.Class listenerClass, java.util.EventListener l)
          Adds a listener of the given class to the list.
 int getListenerCount(java.lang.Class listenerClass)
          Returns the number of listeners present of the given type.
 java.util.EventListener[] getListeners(java.lang.Class listenerClass)
          Returns an array of listeners of the given class.
 void removeListener(java.lang.Class listenerClass, java.util.EventListener l)
          Removes a listener of the given class from the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WeakEventListenerList

public WeakEventListenerList()
Creates a new WeakEventListenerList

Method Detail

addListener

public void addListener(java.lang.Class listenerClass,
                        java.util.EventListener l)
Adds a listener of the given class to the list.

Overrides:
addListener in class EventListenerList
Parameters:
listenerClass - The Class of the listener being added.
l - The listener to add.

getListenerCount

public int getListenerCount(java.lang.Class listenerClass)
Returns the number of listeners present of the given type.

Overrides:
getListenerCount in class EventListenerList
Parameters:
listenerClass - The Class of the listener for which the count is desired.

getListeners

public java.util.EventListener[] getListeners(java.lang.Class listenerClass)
Returns an array of listeners of the given class.

Overrides:
getListeners in class EventListenerList
Parameters:
listenerClass - The Class of listeners which should be returned.
Returns:
An array of listeners of the given Class. If no listeners of the specified class exist, an empty array is returned.

removeListener

public void removeListener(java.lang.Class listenerClass,
                           java.util.EventListener l)
Removes a listener of the given class from the list.

Overrides:
removeListener in class EventListenerList
Parameters:
listenerClass - The Class of the listener being removed.
l - The listener to remove.