@Test public void testDestroy() throws Exception { ReferenceConfigCache cache = ReferenceConfigCache.getCache(); MockReferenceConfig config = buildMockReferenceConfig("FooService", "group1", "1.0.0"); cache.get(config); MockReferenceConfig configCopy = buildMockReferenceConfig("XxxService", "group1", "1.0.0"); cache.get(configCopy); assertEquals(2, cache.cache.size()); cache.destroy(config); assertTrue(config.isDestroyMethodRun()); assertEquals(1, cache.cache.size()); cache.destroy(configCopy); assertTrue(configCopy.isDestroyMethodRun()); assertEquals(0, cache.cache.size()); }
public <T> void destroy(ReferenceConfig<T> referenceConfig) { String key = generator.generateKey(referenceConfig); destroyKey(key); }
ReferenceConfigCache { public <T> void destroy(ReferenceConfig<T> referenceConfig) { String key = generator.generateKey(referenceConfig); destroyKey(key); } }
ReferenceConfigCache { public <T> void destroy(ReferenceConfig<T> referenceConfig) { String key = generator.generateKey(referenceConfig); destroyKey(key); } private  ReferenceConfigCache(String name, KeyGenerator generator); }
ReferenceConfigCache { public <T> void destroy(ReferenceConfig<T> referenceConfig) { String key = generator.generateKey(referenceConfig); 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 <T> void destroy(ReferenceConfig<T> referenceConfig) { String key = generator.generateKey(referenceConfig); 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; }