Search in sources :

Example 1 with UnsolicitedNotificationEvent

use of javax.naming.ldap.UnsolicitedNotificationEvent in project jdk8u_jdk by JetBrains.

the class EventQueue method run.

/**
     * Pull events off the queue and dispatch them.
     */
public void run() {
    QueueElement qe;
    try {
        while ((qe = dequeue()) != null) {
            EventObject e = qe.event;
            Vector<NamingListener> v = qe.vector;
            for (int i = 0; i < v.size(); i++) {
                if (e instanceof NamingEvent) {
                    ((NamingEvent) e).dispatch(v.elementAt(i));
                // An exception occurred: if notify all naming listeners
                } else if (e instanceof NamingExceptionEvent) {
                    ((NamingExceptionEvent) e).dispatch(v.elementAt(i));
                } else if (e instanceof UnsolicitedNotificationEvent) {
                    ((UnsolicitedNotificationEvent) e).dispatch((UnsolicitedNotificationListener) v.elementAt(i));
                }
            }
            qe = null;
            e = null;
            v = null;
        }
    } catch (InterruptedException e) {
    // just die
    }
}
Also used : NamingListener(javax.naming.event.NamingListener) UnsolicitedNotificationEvent(javax.naming.ldap.UnsolicitedNotificationEvent) NamingEvent(javax.naming.event.NamingEvent) NamingExceptionEvent(javax.naming.event.NamingExceptionEvent) EventObject(java.util.EventObject)

Example 2 with UnsolicitedNotificationEvent

use of javax.naming.ldap.UnsolicitedNotificationEvent in project jdk8u_jdk by JetBrains.

the class EventSupport method fireUnsolicited.

/**
     * Fire an event to unsolicited listeners.
     * package private;
     * Called by LdapCtx when its clnt receives an unsolicited notification.
     */
synchronized void fireUnsolicited(Object obj) {
    if (debug) {
        System.err.println("EventSupport.fireUnsolicited: " + obj + " " + unsolicited);
    }
    if (unsolicited == null || unsolicited.size() == 0) {
        // before a fired event event reaches here.
        return;
    }
    if (obj instanceof UnsolicitedNotification) {
        // Fire UnsolicitedNotification to unsolicited listeners
        UnsolicitedNotificationEvent evt = new UnsolicitedNotificationEvent(ctx, (UnsolicitedNotification) obj);
        queueEvent(evt, unsolicited);
    } else if (obj instanceof NamingException) {
        // Fire NamingExceptionEvent to unsolicited listeners.
        NamingExceptionEvent evt = new NamingExceptionEvent(ctx, (NamingException) obj);
        queueEvent(evt, unsolicited);
        // When an exception occurs, the unsolicited listeners
        // are automatically deregistered.
        // When LdapClient.processUnsolicited() fires a NamingException,
        // it will update its listener list so we don't have to.
        // Likewise for LdapCtx.
        unsolicited = null;
    }
}
Also used : UnsolicitedNotificationEvent(javax.naming.ldap.UnsolicitedNotificationEvent) UnsolicitedNotification(javax.naming.ldap.UnsolicitedNotification)

Aggregations

UnsolicitedNotificationEvent (javax.naming.ldap.UnsolicitedNotificationEvent)2 EventObject (java.util.EventObject)1 NamingEvent (javax.naming.event.NamingEvent)1 NamingExceptionEvent (javax.naming.event.NamingExceptionEvent)1 NamingListener (javax.naming.event.NamingListener)1 UnsolicitedNotification (javax.naming.ldap.UnsolicitedNotification)1