ilog.views.util.event
Class IlvEventListenerList

java.lang.Object
  extended by ilog.views.util.event.IlvAbstractEventListenerCollection
      extended by ilog.views.util.event.IlvEventListenerList
All Implemented Interfaces:
IlvEventListenerCollection, Serializable

public class IlvEventListenerList
extends IlvAbstractEventListenerCollection

IlvEventListenerList implements a thread-safe collection of event listeners backed by a list. Some of the pros and cons of using an IlvEventListenerList to manage the event dispatch system for a class are:

  1. IlvEventListenerList provides excellent and nearly constant performance for dispatching events to registered listeners.
  2. Due to its backing list collection, IlvEventListenerList provides excellent performance for adding event listeners, but increasingly poor performance for removing them as the number of registered listeners grows. This is because of the linear search required to find the specified listener.

Here is an example that shows how a class can use an IlvEventListenerList for registering event listeners and dispatching events to them:


   public class MyClass {
       IlvEventListenerCollection xyzListeners = new IlvEventListenerList();

       public void addXYZListener (XYZListener aListener) {
           xyzListeners.addListener(aListener);
       }

       public void removeXYZListener (XYZListener aListener) {
           xyzListeners.removeListener(aListener);
       }

       public void notifyXYZListeners () {
           XYZEvent event = new XYZEvent(this);
           for (Iterator i = xyzListeners.getListeners(); i.hasNext(); ) {
               XYZListener xyzListener = (XYZListener) i.next();
               xyzListener.xyzHappened(event);
           }
       }
   }
 

Since:
JViews 5.5
See Also:
Serialized Form

Constructor Summary
IlvEventListenerList()
          Creates a new IlvEventListenerList.
 
Method Summary
protected  Collection cloneListeners()
          Returns a copy of the collection of event listeners.
protected  void initListeners()
          Initializes the collection of event listeners.
 
Methods inherited from class ilog.views.util.event.IlvAbstractEventListenerCollection
addListener, contains, getListeners, removeListener, save, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvEventListenerList

public IlvEventListenerList()
Creates a new IlvEventListenerList.

Method Detail

initListeners

protected void initListeners()
Initializes the collection of event listeners.

Specified by:
initListeners in class IlvAbstractEventListenerCollection

cloneListeners

protected Collection cloneListeners()
Returns a copy of the collection of event listeners.

Specified by:
cloneListeners in class IlvAbstractEventListenerCollection


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.