private void removeListenerFromChain ( ChainEventListener listener , ChainData chainData ) { ChainGroupData [ ] otherGroups = null ; boolean foundOtherGroupWithListener = false ; // Extract the groups that this chain is involved in. try { otherGroups = this . framework . getAllChainGroups ( chainData . getName ( ) ) ; foundOtherGroupWithListener = false ; int i = 0 ; for ( i = 0 ; i < otherGroups . length ; i ++ ) { if ( ( ( ChainGroupDataImpl ) otherGroups [ i ] ) . containsChainEventListener ( listener ) ) { // Chain is in another group that has this listener. foundOtherGroupWithListener = true ; break ; } } if ( ! foundOtherGroupWithListener ) { // Chain is NOT in another group that has this listener, so listener can // be removed. if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Removing listener from chain config, " + chainData . getName ( ) ) ; } ( ( ChainDataImpl ) chainData ) . removeChainEventListener ( listener ) ; } else { // Chain was found in another group with this listener if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Found chain " + chainData . getName ( ) + " in another group, " + otherGroups [ i ] . getName ( ) ) ; } } } catch ( ChainException e ) { // This shouldn't ever happen, but in case it does, we know no refs were // found. if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Chain not found in config: " + chainData . getName ( ) + ", but will remove listener." ) ; } ( ( ChainDataImpl ) chainData ) . removeChainEventListener ( listener ) ; } }
Remove the listener from the chain but only if the chain is not associated with the listener through another group .