Search in sources :

Example 26 with CacheManager

use of org.cache2k.CacheManager in project cache2k by cache2k.

the class CacheNameTest method managerNameInToString.

@Test
public void managerNameInToString() {
    final String _MANAGER_NAME = "managerNameInToString123";
    CacheManager cm = CacheManager.getInstance(_MANAGER_NAME);
    Cache c = Cache2kBuilder.forUnknownTypes().manager(cm).build();
    assertThat(c.toString(), containsString(_MANAGER_NAME));
    cm.close();
}
Also used : CacheManager(org.cache2k.CacheManager) Cache(org.cache2k.Cache) Test(org.junit.Test)

Example 27 with CacheManager

use of org.cache2k.CacheManager in project cache2k by cache2k.

the class Cache2kCoreProviderImpl method close.

@Override
public void close(ClassLoader cl, String managerName) {
    if (cl == null) {
        cl = getDefaultClassLoader();
    }
    CacheManager cm;
    Map<String, CacheManager> map = loader2name2manager.get(cl);
    if (map == null) {
        return;
    }
    cm = map.get(managerName);
    if (cm == null) {
        return;
    }
    cm.close();
}
Also used : CacheManager(org.cache2k.CacheManager)

Aggregations

CacheManager (org.cache2k.CacheManager)27 Test (org.junit.Test)24 Cache (org.cache2k.Cache)11 MBeanInfo (javax.management.MBeanInfo)4 URLClassLoader (java.net.URLClassLoader)3 Cache2kBuilder (org.cache2k.Cache2kBuilder)3 Log (org.cache2k.core.util.Log)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 WeakHashMap (java.util.WeakHashMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 CacheEntry (org.cache2k.CacheEntry)1 Cache2kConfiguration (org.cache2k.configuration.Cache2kConfiguration)1 CacheEntryCreatedListener (org.cache2k.event.CacheEntryCreatedListener)1