It is constructed using a second object, the manager's processor which will be invoked whenever new events are available in the event FIFO queue. the processor is then responsible for querying all registered listeners and calling their appropriate event listening methods.
Event dispatching is deferred to the Swing thread execution time since this makes the whole application much more predictable and easily synchronizable. @author Hanns Holger Rutz @version 0.18, 08-Apr-08
EventManager
will record the request internally and register the event with the virtual machine, which may choose to handle the request itself (as is likely the case with breakpoints and other execution-related events), or it may decide to allow the EventManager
to handle notifications and all filtering (which is convenient for other events such as class (un)loading).
@author Keith Seitz (keiths@redhat.com)
Service to manage event notification. The designed has been inspired by the paper by Gupta, S., J. M. Hartkopf, and S. Ramaswamy, in Java Report, Vol. 3, No. 7, July 1998, 19-36, "Event Notifier: A Pattern for Event Notification".
EventManager brokers events between a Publisher, which produces events, and a Subscriber, which handles the notification of events. A Filter discards events not of interest to a subscriber. All Events have a common ancestor type Event and the event types are identified by a Class.
@author Carsten Ziegeler @author Volker Schmitt @author Mauro Talevi @version CVS $Id: EventManager.java 30932 2004-07-29 17:35:38Z vgritsenko $At first glance, this package may seem more complicated than necessary but it has support for some important features. The listener list supports companion objects for each listener object. This is used by the OSGi framework to create wrapper objects for a listener which are passed to the event dispatcher. The ListenerQueue class is used to build a snap shot of the listeners prior to beginning event dispatch. The OSGi framework uses a 2 level listener list for each listener type (4 types). Level one is managed per framework instance and contains the list of BundleContexts which have registered a listener. Level 2 is managed per BundleContext for the listeners in that context. This allows all the listeners of a bundle to be easily and atomically removed from the level one list. To use a "flat" list for all bundles would require the list to know which bundle registered a listener object so that the list could be traversed when stopping a bundle to remove all the bundle's listeners. When an event is fired, a snapshot list (ListenerQueue) must be made of the current listeners before delivery is attempted. The snapshot list is necessary to allow the listener list to be modified while the event is being delivered to the snapshot list. The memory cost of the snapshot list is low since the ListenerQueue object uses the copy-on-write semantics of the CopyOnWriteIdentityMap. This guarantees the snapshot list is never modified once created. The OSGi framework also uses a 2 level dispatch technique (EventDispatcher). Level one dispatch is used by the framework to add the level 2 listener list of each BundleContext to the snapshot in preparation for delivery of the event. Level 2 dispatch is used as the final event deliverer and must cast the listener and event objects to the proper type before calling the listener. Level 2 dispatch will cancel delivery of an event to a bundle that has stopped between the time the snapshot was created and the attempt was made to deliver the event.
The highly dynamic nature of the OSGi framework had necessitated these features for proper and efficient event delivery. @since 3.1 @noextend This class is not intended to be subclassed by clients.
Copyright © 2003-2004 The MITRE Corporation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|