@Override public void cacheRemoved(String alias, Cache<?, ?> cache) { collector.onNotification( new ContextualNotification( configuration.getContext().with("cacheName", alias), EhcacheNotification.CACHE_REMOVED.name())); }
private void cacheCleared(String alias) { collector.onNotification( new ContextualNotification( configuration.getContext().with("cacheName", alias), EhcacheNotification.CACHE_CLEARED.name())); }
@Override public synchronized void stop() { // do not call deregisterListener here because the stateTransition event for UNINITIALIZED won't be caught. // so deregisterListener is done in the stateTransition listener //cacheManager.deregisterListener(this); collector.onNotification( new ContextualNotification( configuration.getContext(), EhcacheNotification.CACHE_MANAGER_CLOSED.name())); statisticCollector.stopStatisticCollector(); shutdownNow(scheduledExecutorService); }
@Override public void cacheAdded(String alias, Cache<?, ?> cache) { registerClearNotification(alias, cache); collector.onNotification( new ContextualNotification( configuration.getContext().with("cacheName", alias), EhcacheNotification.CACHE_ADDED.name())); }
@Override public void stateTransition(Status from, Status to) { switch (to) { case AVAILABLE: // .register() call should be there when CM is AVAILABLE // this is to expose the stats collector for management calls managementRegistry.register(statisticCollector); collector.onNotification( new ContextualNotification( configuration.getContext(), EhcacheNotification.CACHE_MANAGER_AVAILABLE.name())); break; case MAINTENANCE: collector.onNotification( new ContextualNotification( configuration.getContext(), EhcacheNotification.CACHE_MANAGER_MAINTENANCE.name())); break; case UNINITIALIZED: // deregister me - should not be in stop() - see other comments cacheManager.deregisterListener(this); break; default: throw new AssertionError("Unsupported state: " + to); } }