@Test public void testDestroyAll() throws Exception { ReferenceConfigCache cache = ReferenceConfigCache.getCache(); MockReferenceConfig config = new MockReferenceConfig(); config.setInterface("FooService"); config.setGroup("group1"); config.setVersion("1.0.0"); cache.get(config); MockReferenceConfig configCopy = new MockReferenceConfig(); configCopy.setInterface("XxxService"); configCopy.setGroup("group1"); configCopy.setVersion("1.0.0"); cache.get(configCopy); assertEquals(2, cache.cache.size()); cache.destroyAll(); assertTrue(config.isDestroyMethodRun()); assertTrue(configCopy.isDestroyMethodRun()); assertEquals(0, cache.cache.size()); }
public void destroyAll() { Set<String> set = new HashSet<>(cache.keySet()); for (String key : set) { destroyKey(key); } }
ReferenceConfigCache { public void destroyAll() { Set<String> set = new HashSet<>(cache.keySet()); for (String key : set) { destroyKey(key); } } }
ReferenceConfigCache { public void destroyAll() { Set<String> set = new HashSet<>(cache.keySet()); for (String key : set) { destroyKey(key); } } private  ReferenceConfigCache(String name, KeyGenerator generator); }
ReferenceConfigCache { public void destroyAll() { Set<String> set = new HashSet<>(cache.keySet()); for (String key : set) { destroyKey(key); } } private  ReferenceConfigCache(String name, KeyGenerator generator); static ReferenceConfigCache getCache(); static ReferenceConfigCache getCache(String name); static ReferenceConfigCache getCache(String name, KeyGenerator keyGenerator); @SuppressWarnings("unchecked") T get(ReferenceConfig<T> referenceConfig); void destroy(ReferenceConfig<T> referenceConfig); void destroyAll(); @Override String toString(); }
ReferenceConfigCache { public void destroyAll() { Set<String> set = new HashSet<>(cache.keySet()); for (String key : set) { destroyKey(key); } } private  ReferenceConfigCache(String name, KeyGenerator generator); static ReferenceConfigCache getCache(); static ReferenceConfigCache getCache(String name); static ReferenceConfigCache getCache(String name, KeyGenerator keyGenerator); @SuppressWarnings("unchecked") T get(ReferenceConfig<T> referenceConfig); void destroy(ReferenceConfig<T> referenceConfig); void destroyAll(); @Override String toString(); static final String DEFAULT_NAME; static final KeyGenerator DEFAULT_KEY_GENERATOR; }