@Override public void destroy() { if (this.cacheManager != null) { this.cacheManager.close(); } }
@Override protected void releaseFromUse() { try { // todo (5.3) : if this is a manager instance that was provided to us we should probably not close it... // - when the explicit `setting` passed to `#useExplicitCacheManager` is // a CacheManager instance cacheManager.close(); } finally { cacheManager = null; } } }
@Override public void destroy() { if (this.cacheManager != null) { this.cacheManager.close(); } }
@Override public void close(ClassLoader classLoader) { Map<URI, CacheManager> uri2manager = managers.remove(classLoader); if (uri2manager != null) { for (CacheManager manager : uri2manager.values()) { manager.close(); } } }
@Override public void close(ClassLoader classLoader) { Map<URI, CacheManager> uri2manager = managers.remove(classLoader); if (uri2manager != null) { for (CacheManager manager : uri2manager.values()) { manager.close(); } } }
@Override public void close(URI uri, ClassLoader classLoader) { Map<URI, CacheManager> uri2manager = managers.get(classLoader); if (uri2manager == null) { return; } CacheManager manager = uri2manager.remove(uri); if (manager == null) { return; } manager.close(); if (uri2manager.isEmpty()) { managers.remove(classLoader, Collections.emptyMap()); } }
@Override public void close(URI uri, ClassLoader classLoader) { Map<URI, CacheManager> uri2manager = managers.get(classLoader); if (uri2manager == null) { return; } CacheManager manager = uri2manager.remove(uri); if (manager == null) { return; } manager.close(); if (uri2manager.isEmpty()) { managers.remove(classLoader, Collections.emptyMap()); } }
@Override public void close(ClassLoader classLoader) { synchronized (cacheManagers) { ClassLoader managerClassLoader = getManagerClassLoader(classLoader); Map<URI, CacheManager> cacheManagersByURI = cacheManagers.remove(managerClassLoader); if (cacheManagersByURI != null) { for (CacheManager cacheManager : cacheManagersByURI.values()) { cacheManager.close(); } } } }
@Override public void close(URI uri, ClassLoader classLoader) { synchronized (cacheManagers) { ClassLoader managerClassLoader = getManagerClassLoader(classLoader); Map<URI, CacheManager> cacheManagersByURI = cacheManagers.get(managerClassLoader); if (cacheManagersByURI != null) { CacheManager cacheManager = cacheManagersByURI.remove(getManagerUri(uri)); if (cacheManager != null) { cacheManager.close(); } if (cacheManagersByURI.isEmpty()) { cacheManagers.remove(managerClassLoader); } } } }
@After public void shutdown() { if (this.cacheManager != null) { this.cacheManager.close(); } }
@After public void shutdown() { if (jCacheManager != null) { jCacheManager.close(); } }
@After public void after() { if(cacheManager != null) { cacheManager.close(); } }
@After public void tearDown() { cacheManager.close(); }
@After public void tearDown() throws Exception { cacheManager.close(); }
@After public void tearDown() throws Exception { cacheManager.close(); }
@After public void tearDown() { cacheManager.close(); }
@After public void tearDown() { cacheManager.close(); }
@After public void tearDown() throws Exception { if(cacheManager != null) { cacheManager.close(); } if(cachingProvider != null) { cachingProvider.close(); } }
@Test public void testCacheManagerCloseLenientToEhcacheClosed() throws Exception { CachingProvider provider = Caching.getCachingProvider(); javax.cache.CacheManager cacheManager = provider.getCacheManager(this.getClass() .getResource("/ehcache-107-types.xml") .toURI(), getClass().getClassLoader()); MutableConfiguration<Long, String> cache1Conf = new MutableConfiguration<>(); javax.cache.Cache<Long, String> cache = cacheManager.createCache("cache1", cache1Conf); cacheManager.unwrap(org.ehcache.CacheManager.class).removeCache(cache.getName()); cacheManager.close(); } }
@Test public void testCacheUnwrap() { MutableConfiguration<String, String> configuration = new MutableConfiguration<>(); configuration.setTypes(String.class, String.class); Cache<String, String> cache = cacheManager.createCache("cache", configuration); assertThat(cache.unwrap(org.ehcache.Cache.class), is(instanceOf(org.ehcache.Cache.class))); assertThat(cache.unwrap(cache.getClass()), is(instanceOf(Eh107Cache.class))); cacheManager.close(); }