src/share/classes/com/sun/jndi/ldap/NamingEventNotifier.java

Print this page
rev 10195 : 8048267: Replace uses of 'new Long()' with appropriate alternative across core classes
Reviewed-by: chegar, psandoz
Contributed-by: otaviojava@java.net


 204     /**
 205      * Stop the dispatcher so we can be destroyed.
 206      * package private; used by EventSupport
 207      */
 208     void stop() {
 209         if (debug) System.err.println("NamingEventNotifier being stopping");
 210         if (worker != null) {
 211             worker.interrupt(); // kill our thread
 212             worker = null;
 213         }
 214     }
 215 
 216     /**
 217      * Fire an "object added" event to registered NamingListeners.
 218      */
 219     private void fireObjectAdded(Binding newBd, long changeID) {
 220         if (namingListeners == null || namingListeners.size() == 0)
 221             return;
 222 
 223         NamingEvent e = new NamingEvent(eventSrc, NamingEvent.OBJECT_ADDED,
 224             newBd, null, new Long(changeID));
 225         support.queueEvent(e, namingListeners);
 226     }
 227 
 228     /**
 229      * Fire an "object removed" event to registered NamingListeners.
 230      */
 231     private void fireObjectRemoved(Binding oldBd, long changeID) {
 232         if (namingListeners == null || namingListeners.size() == 0)
 233             return;
 234 
 235         NamingEvent e = new NamingEvent(eventSrc, NamingEvent.OBJECT_REMOVED,
 236             null, oldBd, new Long(changeID));
 237         support.queueEvent(e, namingListeners);
 238     }
 239 
 240     /**
 241      * Fires an "object changed" event to registered NamingListeners.
 242      */
 243     private void fireObjectChanged(Binding newBd, long changeID) {
 244         if (namingListeners == null || namingListeners.size() == 0)
 245             return;
 246 
 247         // Name hasn't changed; construct old binding using name from new binding
 248         Binding oldBd = new Binding(newBd.getName(), null, newBd.isRelative());
 249 
 250         NamingEvent e = new NamingEvent(
 251             eventSrc, NamingEvent.OBJECT_CHANGED, newBd, oldBd, new Long(changeID));
 252         support.queueEvent(e, namingListeners);
 253     }
 254 
 255     /**
 256      * Fires an "object renamed" to registered NamingListeners.
 257      */
 258     private void fireObjectRenamed(Binding newBd, String oldDN, long changeID) {
 259         if (namingListeners == null || namingListeners.size() == 0)
 260             return;
 261 
 262         Binding oldBd = null;
 263         try {
 264             LdapName dn = new LdapName(oldDN);
 265             if (dn.startsWith(context.currentParsedDN)) {
 266                 String relDN = dn.getSuffix(context.currentParsedDN.size()).toString();
 267                 oldBd = new Binding(relDN, null);
 268             }
 269         } catch (NamingException e) {}
 270 
 271         if (oldBd == null) {
 272             oldBd = new Binding(oldDN, null, false /* not relative name */);
 273         }
 274 
 275         NamingEvent e = new NamingEvent(
 276             eventSrc, NamingEvent.OBJECT_RENAMED, newBd, oldBd, new Long(changeID));
 277         support.queueEvent(e, namingListeners);
 278     }
 279 
 280     private void fireNamingException(NamingException e) {
 281         if (namingListeners == null || namingListeners.size() == 0)
 282             return;
 283 
 284         NamingExceptionEvent evt = new NamingExceptionEvent(eventSrc, e);
 285         support.queueEvent(evt, namingListeners);
 286     }
 287 }


 204     /**
 205      * Stop the dispatcher so we can be destroyed.
 206      * package private; used by EventSupport
 207      */
 208     void stop() {
 209         if (debug) System.err.println("NamingEventNotifier being stopping");
 210         if (worker != null) {
 211             worker.interrupt(); // kill our thread
 212             worker = null;
 213         }
 214     }
 215 
 216     /**
 217      * Fire an "object added" event to registered NamingListeners.
 218      */
 219     private void fireObjectAdded(Binding newBd, long changeID) {
 220         if (namingListeners == null || namingListeners.size() == 0)
 221             return;
 222 
 223         NamingEvent e = new NamingEvent(eventSrc, NamingEvent.OBJECT_ADDED,
 224             newBd, null, changeID);
 225         support.queueEvent(e, namingListeners);
 226     }
 227 
 228     /**
 229      * Fire an "object removed" event to registered NamingListeners.
 230      */
 231     private void fireObjectRemoved(Binding oldBd, long changeID) {
 232         if (namingListeners == null || namingListeners.size() == 0)
 233             return;
 234 
 235         NamingEvent e = new NamingEvent(eventSrc, NamingEvent.OBJECT_REMOVED,
 236             null, oldBd, changeID);
 237         support.queueEvent(e, namingListeners);
 238     }
 239 
 240     /**
 241      * Fires an "object changed" event to registered NamingListeners.
 242      */
 243     private void fireObjectChanged(Binding newBd, long changeID) {
 244         if (namingListeners == null || namingListeners.size() == 0)
 245             return;
 246 
 247         // Name hasn't changed; construct old binding using name from new binding
 248         Binding oldBd = new Binding(newBd.getName(), null, newBd.isRelative());
 249 
 250         NamingEvent e = new NamingEvent(
 251             eventSrc, NamingEvent.OBJECT_CHANGED, newBd, oldBd, changeID);
 252         support.queueEvent(e, namingListeners);
 253     }
 254 
 255     /**
 256      * Fires an "object renamed" to registered NamingListeners.
 257      */
 258     private void fireObjectRenamed(Binding newBd, String oldDN, long changeID) {
 259         if (namingListeners == null || namingListeners.size() == 0)
 260             return;
 261 
 262         Binding oldBd = null;
 263         try {
 264             LdapName dn = new LdapName(oldDN);
 265             if (dn.startsWith(context.currentParsedDN)) {
 266                 String relDN = dn.getSuffix(context.currentParsedDN.size()).toString();
 267                 oldBd = new Binding(relDN, null);
 268             }
 269         } catch (NamingException e) {}
 270 
 271         if (oldBd == null) {
 272             oldBd = new Binding(oldDN, null, false /* not relative name */);
 273         }
 274 
 275         NamingEvent e = new NamingEvent(
 276             eventSrc, NamingEvent.OBJECT_RENAMED, newBd, oldBd, changeID);
 277         support.queueEvent(e, namingListeners);
 278     }
 279 
 280     private void fireNamingException(NamingException e) {
 281         if (namingListeners == null || namingListeners.size() == 0)
 282             return;
 283 
 284         NamingExceptionEvent evt = new NamingExceptionEvent(eventSrc, e);
 285         support.queueEvent(evt, namingListeners);
 286     }
 287 }