final boolean trace = log.isTraceEnabled();
if (trace)
{
log.trace("Check whether all timers are cancelled or expired for this entity: " + id);
}
final EJBTimerService service = container.getTimerService();
final ObjectName containerId = container.getJmxName();
AccessController.doPrivileged(new PrivilegedAction<Object>()
{
public Object run()
{
TimerService timerService = service.getTimerService(containerId, id);
if (timerService != null && timerService.getTimers().isEmpty())
{
// Assuming that active timers do not include cancelled or expired ones.
if (trace)
{
log.trace("No active timers available for " + containerId + " and primary key " + id);
}
service.removeTimerService(containerId, id);
}
return null;
}
});
}