public static void removeTimersByJ2EEName ( J2EEName j2eeName ) { final boolean isTraceOn = TraceComponent . isAnyTracingEnabled ( ) ; if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . entry ( tc , "removeTimersByJ2EEName: " + j2eeName ) ; Collection < TimerNpImpl > timersToRemove = null ; // Although this seems inefficient, removing all of the timers for an // application or module that is stopping is done in two steps to avoid // obtaining locks on both the active timers map and any individual // timer concurrently. Many methods on a timer will also need to obtain // the lock on the active timers map as well, so the two step approach // avoids the possibility of deadlock. RTC107334 synchronized ( svActiveTimers ) { if ( svActiveTimers . size ( ) > 0 ) { String appToRemove = j2eeName . getApplication ( ) ; String modToRemove = j2eeName . getModule ( ) ; for ( TimerNpImpl timer : svActiveTimers . values ( ) ) { J2EEName timerJ2EEName = timer . ivBeanId . j2eeName ; if ( appToRemove . equals ( timerJ2EEName . getApplication ( ) ) && ( modToRemove == null || modToRemove . equals ( timerJ2EEName . getModule ( ) ) ) ) { // save the timer to be removed outside the active timers map lock if ( timersToRemove == null ) { timersToRemove = new ArrayList < TimerNpImpl > ( ) ; } timersToRemove . add ( timer ) ; } } } } if ( timersToRemove != null ) { for ( TimerNpImpl timer : timersToRemove ) { timer . remove ( true ) ; // permanently remove the timer; cannot be rolled back } } if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . exit ( tc , "removeTimersByJ2EEName: removed " + ( timersToRemove != null ? timersToRemove . size ( ) : 0 ) ) ; }
Removes all timers associated with the specified application or module .