< prev index next >

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

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 26,35 **** --- 26,37 ---- package com.sun.jndi.ldap; import java.util.Hashtable; import java.util.Vector; import java.util.EventObject; + import java.util.Iterator; + import java.util.Map; import javax.naming.*; import javax.naming.event.*; import javax.naming.directory.SearchControls; import javax.naming.ldap.UnsolicitedNotificationListener;
*** 202,236 **** /** * Removes {@code l} from all notifiers in this context. */ synchronized void removeNamingListener(NamingListener l) { ! if (debug) System.err.println("EventSupport removing listener"); ! // Go through list of notifiers, remove 'l' from each. // If 'l' is notifier's only listener, remove notifier too. ! for (NamingEventNotifier notifier : notifiers.values()) { if (notifier != null) { ! if (debug) System.err.println("EventSupport removing listener from notifier"); notifier.removeNamingListener(l); if (!notifier.hasNamingListeners()) { ! if (debug) System.err.println("EventSupport stopping notifier"); notifier.stop(); ! notifiers.remove(notifier.info); } } } - // Remove from list of unsolicited notifier ! if (debug) System.err.println("EventSupport removing unsolicited: " + ! unsolicited); if (unsolicited != null) { unsolicited.removeElement(l); } - } synchronized boolean hasUnsolicited() { return (unsolicited != null && unsolicited.size() > 0); } --- 204,244 ---- /** * Removes {@code l} from all notifiers in this context. */ synchronized void removeNamingListener(NamingListener l) { ! if (debug) { ! System.err.println("EventSupport removing listener"); ! } // Go through list of notifiers, remove 'l' from each. // If 'l' is notifier's only listener, remove notifier too. ! Iterator<Map.Entry<NotifierArgs, NamingEventNotifier>> allnotifiers; ! allnotifiers = notifiers.entrySet().iterator(); ! while (allnotifiers.hasNext()) { ! Map.Entry<NotifierArgs, NamingEventNotifier> entry = allnotifiers.next(); ! NamingEventNotifier notifier = entry.getValue(); if (notifier != null) { ! if (debug) { System.err.println("EventSupport removing listener from notifier"); + } notifier.removeNamingListener(l); if (!notifier.hasNamingListeners()) { ! if (debug) { System.err.println("EventSupport stopping notifier"); + } notifier.stop(); ! allnotifiers.remove(); } } } // Remove from list of unsolicited notifier ! if (debug) { ! System.err.println("EventSupport removing unsolicited: " + unsolicited); ! } if (unsolicited != null) { unsolicited.removeElement(l); } } synchronized boolean hasUnsolicited() { return (unsolicited != null && unsolicited.size() > 0); }
< prev index next >