|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.mbari.siam.core.EventManager
public class EventManager
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
protected static final int LOG_MODULUS
protected java.util.Vector _listenerList
| Method Detail |
|---|
public static EventManager getInstance()
public void addListener(java.lang.Class type,
java.util.EventListener listener)
public void postEvent(NodeEvent event)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||