Class EventManager

  extended by org.mbari.siam.core.EventManager

public class EventManager
extends java.lang.Object

EventManager is a mechanism for notifying objects of system level events. It is superficially similar to the AWT event model. Custom AWT events were not used for several reasons: The EventManager is implemented as a singleton; it is typically started by the NodeManger. It has a Queue member field, which implements the event queue thread. Once created, the EventManager waits for events to be posted; when an event is posted, a DispatchThread (internal class) is created to dispatch the event to all listeners registered for that event type. Each listener for a given event type implements a corresponding listener interface, containing methods called by the dispatch thread. Note that each dispatch thread calls the listener methods sequentially; a rougue listener could delay or hang the dispatch thread. ** Above was changed in revision 1.8. Now the EventDispatcher thread is created and allocated, one per listener. When an event comes in, it is posted to each EventDispatcher that handles an event of that type. This resolves the problem noted above, where a rogue listener can hang the dispatch thread. With this version, and rogue listener only hangs itself. rah, 6Dec2007. Also with this revision, AWT or Swing events are no longer used. rah, 6Dec2007. Objects may register as listeners of various event types, or post events to the EventManager queue. There are currently four event types: ServiceEvent, SchedulerEvent, PowerEvent, and CommEvent All event types must be extended from NodeEvent, which extends java.util.EventObject.

Field Summary
protected  java.util.Vector _listenerList
          Event Queue
protected static int LOG_MODULUS
protected static int MAX_QUEUE_SIZE
Method Summary
 void addListener(java.lang.Class type, java.util.EventListener listener)
          Add Listener for event type.
static EventManager getInstance()
          Get EventManager Instance
 void postEvent(NodeEvent event)
          Post an event to the EventQueue
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


protected static final int MAX_QUEUE_SIZE
See Also:
Constant Field Values


protected static final int LOG_MODULUS
See Also:
Constant Field Values


protected java.util.Vector _listenerList
Event Queue

Method Detail


public static EventManager getInstance()
Get EventManager Instance


public void addListener(java.lang.Class type,
                        java.util.EventListener listener)
Add Listener for event type. Note that, starting with revision 1.8, the type parameter is unused.


public void postEvent(NodeEvent event)
Post an event to the EventQueue

Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.