synchronized void removeListener ( final NamingListener namingListener ) { // Do we have a holder for this listener final ListenerHolder holder = holdersByListener . get ( namingListener ) ; if ( holder == null ) { return ; } final Map < NamingListener , ListenerHolder > byListenerCopy = new FastCopyHashMap < NamingListener , ListenerHolder > ( holdersByListener ) ; byListenerCopy . remove ( namingListener ) ; holdersByListener = byListenerCopy ; final Map < TargetScope , List < ListenerHolder > > byTargetCopy = new FastCopyHashMap < TargetScope , List < ListenerHolder > > ( holdersByTarget ) ; for ( TargetScope targetScope : holder . targets ) { final List < ListenerHolder > holders = holdersByTarget . get ( targetScope ) ; holders . remove ( holder ) ; if ( holders . isEmpty ( ) ) { byTargetCopy . remove ( targetScope ) ; } } holdersByTarget = byTargetCopy ; }
Remove a listener . Will remove it from all target mappings . Once this method returns the listener will no longer receive any events .