< prev index next >

src/java.naming/share/classes/com/sun/jndi/ldap/EventQueue.java

Print this page




  56         QueueElement(EventObject event, Vector<NamingListener> vector) {
  57             this.event = event;
  58             this.vector = vector;
  59         }
  60     }
  61 
  62     private QueueElement head = null;
  63     private QueueElement tail = null;
  64     private Thread qThread;
  65 
  66     // package private
  67     EventQueue() {
  68         qThread = Obj.helper.createThread(this);
  69         qThread.setDaemon(true);  // not a user thread
  70         qThread.start();
  71     }
  72 
  73     // package private;
  74     /**
  75      * Enqueue an event.
  76      * @param event Either a <tt>NamingExceptionEvent</tt> or a subclass
  77      *              of <tt>NamingEvent</tt> or
  78      * <tt>UnsolicitedNotificationEvent</tt>.
  79      * If it is a subclass of <tt>NamingEvent</tt>, all listeners must implement
  80      * the corresponding subinterface of <tt>NamingListener</tt>.
  81      * For example, for a <tt>ObjectAddedEvent</tt>, all listeners <em>must</em>
  82      * implement the <tt>ObjectAddedListener</tt> interface.
  83      * <em>The current implementation does not check this before dispatching
  84      * the event.</em>
  85      * If the event is a <tt>NamingExceptionEvent</tt>, then all listeners
  86      * are notified.
  87      * @param vector List of NamingListeners that will be notified of event.
  88      */
  89     synchronized void enqueue(EventObject event, Vector<NamingListener> vector) {
  90         QueueElement newElt = new QueueElement(event, vector);
  91 
  92         if (head == null) {
  93             head = newElt;
  94             tail = newElt;
  95         } else {
  96             newElt.next = head;
  97             head.prev = newElt;
  98             head = newElt;
  99         }
 100         notify();
 101     }
 102 
 103     /**
 104      * Dequeue the oldest object on the queue.
 105      * Used only by the run() method.




  56         QueueElement(EventObject event, Vector<NamingListener> vector) {
  57             this.event = event;
  58             this.vector = vector;
  59         }
  60     }
  61 
  62     private QueueElement head = null;
  63     private QueueElement tail = null;
  64     private Thread qThread;
  65 
  66     // package private
  67     EventQueue() {
  68         qThread = Obj.helper.createThread(this);
  69         qThread.setDaemon(true);  // not a user thread
  70         qThread.start();
  71     }
  72 
  73     // package private;
  74     /**
  75      * Enqueue an event.
  76      * @param event Either a {@code NamingExceptionEvent} or a subclass
  77      *        of {@code NamingEvent} or
  78      *        {@code UnsolicitedNotificationEvent}.
  79      * If it is a subclass of {@code NamingEvent}, all listeners must implement
  80      * the corresponding subinterface of {@code NamingListener}.
  81      * For example, for a {@code ObjectAddedEvent}, all listeners <em>must</em>
  82      * implement the {@code ObjectAddedListener} interface.
  83      * <em>The current implementation does not check this before dispatching
  84      * the event.</em>
  85      * If the event is a {@code NamingExceptionEvent}, then all listeners
  86      * are notified.
  87      * @param vector List of NamingListeners that will be notified of event.
  88      */
  89     synchronized void enqueue(EventObject event, Vector<NamingListener> vector) {
  90         QueueElement newElt = new QueueElement(event, vector);
  91 
  92         if (head == null) {
  93             head = newElt;
  94             tail = newElt;
  95         } else {
  96             newElt.next = head;
  97             head.prev = newElt;
  98             head = newElt;
  99         }
 100         notify();
 101     }
 102 
 103     /**
 104      * Dequeue the oldest object on the queue.
 105      * Used only by the run() method.


< prev index next >