EhcachePortalCache extends BasePortalCache<K, V> implements EhcacheWrapper { protected void reconfigEhcache(Ehcache ehcache) { RegisteredEventListeners registeredEventListeners = ehcache.getCacheEventNotificationService(); registeredEventListeners.registerListener( new PortalCacheCacheEventListener<>( aggregatedPortalCacheListener, this), NotificationScope.ALL); Ehcache oldEhcache = this.ehcache; this.ehcache = ehcache; registeredEventListeners = oldEhcache.getCacheEventNotificationService(); Set<CacheEventListener> cacheEventListeners = registeredEventListeners.getCacheEventListeners(); for (CacheEventListener cacheEventListener : cacheEventListeners) { registeredEventListeners.unregisterListener(cacheEventListener); } } EhcachePortalCache(
		PortalCacheManager<K, V> portalCacheManager, Ehcache ehcache); @Override Ehcache getEhcache(); @Override List<K> getKeys(); @Override String getPortalCacheName(); @Override void removeAll();  }
@Test public void testReconfigEhcache() { Assert.assertSame(_ehcache, _ehcachePortalCache.ehcache); Map<PortalCacheListener<String, String>, PortalCacheListenerScope> oldPortalCacheListeners = _ehcachePortalCache.getPortalCacheListeners(); _cacheManager.addCache(_NEW_PORTAL_CACHE_NAME); Ehcache ehcache2 = _cacheManager.getCache(_NEW_PORTAL_CACHE_NAME); _ehcachePortalCache.reconfigEhcache(ehcache2); Assert.assertSame(ehcache2, _ehcachePortalCache.ehcache); Assert.assertEquals( oldPortalCacheListeners, _ehcachePortalCache.getPortalCacheListeners()); RegisteredEventListeners registeredEventListeners = _ehcache.getCacheEventNotificationService(); Set<CacheEventListener> cacheEventListeners = registeredEventListeners.getCacheEventListeners(); Assert.assertTrue( cacheEventListeners.toString(), cacheEventListeners.isEmpty()); registeredEventListeners = ehcache2.getCacheEventNotificationService(); cacheEventListeners = registeredEventListeners.getCacheEventListeners(); Assert.assertFalse( cacheEventListeners.toString(), cacheEventListeners.isEmpty()); }