This class supports two types of listeners: those that register for NamingEvents, and those for UnsolicitedNotificationEvents (they can be mixed into the same listener). For NamingEvent listeners, it maintains a hashtable that maps registration requests--the key--to notifiers--the value. Each registration request consists of:
NamingListener interface the listener supports.
A notifier (NamingEventNotifier) is a worker thread that is responsible
for gathering information for generating events requested by its listeners.
Each notifier maintains its own list of listeners; these listeners have
all made the same registration request (at different times) and implements
the same NamingListener interfaces.
For unsolicited listeners, this class maintains a vector, unsolicited. When an unsolicited listener is registered, this class adds itself to the context's LdapClient. When LdapClient receives an unsolicited notification, it notifies this EventSupport to fire an event to the the listeners. Special handling in LdapClient is done for the DISCONNECT notification. [It results in the EventSupport firing also a NamingExceptionEvent to the unsolicited listeners.]
When a context no longer needs this EventSupport, it should invoke cleanup() on it.
fireXXXEvent on this class with the information and list of
listeners. This causes an event and the list of listeners to be added
to the event queue.
This class maintains an event queue and a dispatching thread that dequeues
events from the queue and dispatches them to the listeners.
| Modifier and Type | Field and Description |
|---|---|
| private LdapCtx | |
| private static final boolean | |
| private EventQueue | |
| pack-priv final ReentrantLock | |
| private Hashtable | notifiers
NamingEventNotifiers; hashed by search arguments; |
| private Vector | unsolicited
List of unsolicited notification listeners. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | addNamingListener(String nm, int scope, NamingListener l)
Adds |
| pack-priv void | addNamingListener(String nm, String filter, SearchControls ctls, NamingListener l)
Adds |
| pack-priv void | cleanup()
Stops notifier threads that are collecting event data and stops the event queue from dispatching events. |
| pack-priv void | |
| pack-priv boolean | |
| pack-priv void | queueEvent(EventObject event, Vector<? extends NamingListener> vector)
Add the event and vector of listeners to the queue to be delivered. |
| pack-priv void | removeDeadNotifier(NotifierArgs info)
package private; Called by NamingEventNotifier to remove itself when it encounters a NamingException. |
| pack-priv void |
| ctx | back to summary |
|---|---|
| private LdapCtx ctx | |
| debug | back to summary |
|---|---|
| private static final boolean debug | |
| eventQueue | back to summary |
|---|---|
| private EventQueue eventQueue | |
| lock | back to summary |
|---|---|
| pack-priv final ReentrantLock lock | |
| notifiers | back to summary |
|---|---|
| private Hashtable<NotifierArgs, NamingEventNotifier> notifiers NamingEventNotifiers; hashed by search arguments; | |
| unsolicited | back to summary |
|---|---|
| private Vector<UnsolicitedNotificationListener> unsolicited List of unsolicited notification listeners. | |
| EventSupport | back to summary |
|---|---|
| pack-priv EventSupport(LdapCtx ctx) Constructs EventSupport for ctx. Do we need to record the name of the target context? Or can we assume that EventSupport is called on a resolved context? Do we need other add/remove-NamingListener methods? package private; | |
| addNamingListener | back to summary |
|---|---|
| pack-priv void addNamingListener(String nm, int scope, NamingListener l) throws NamingException Adds | |
| addNamingListener | back to summary |
|---|---|
| pack-priv void addNamingListener(String nm, String filter, SearchControls ctls, NamingListener l) throws NamingException Adds | |
| cleanup | back to summary |
|---|---|
| pack-priv void cleanup() Stops notifier threads that are collecting event data and stops the event queue from dispatching events. Package private; used by LdapCtx. | |
| fireUnsolicited | back to summary |
|---|---|
| pack-priv void fireUnsolicited(Object obj) Fire an event to unsolicited listeners. package private; Called by LdapCtx when its clnt receives an unsolicited notification. | |
| hasUnsolicited | back to summary |
|---|---|
| pack-priv boolean hasUnsolicited() | |
| queueEvent | back to summary |
|---|---|
| pack-priv void queueEvent(EventObject event, Vector<? extends NamingListener> vector) Add the event and vector of listeners to the queue to be delivered. An event dispatcher thread dequeues events from the queue and dispatches them to the registered listeners. Package private; used by NamingEventNotifier to fire events | |
| removeDeadNotifier | back to summary |
|---|---|
| pack-priv void removeDeadNotifier(NotifierArgs info) package private; Called by NamingEventNotifier to remove itself when it encounters a NamingException. | |
| removeNamingListener | back to summary |
|---|---|
| pack-priv void removeNamingListener(NamingListener l) Removes | |