use of org.cache2k.CacheManager in project cache2k by cache2k.
the class CacheManagerLifeCycleTest method closesCache.
@Test
public void closesCache() {
String _uniqueName = this.getClass().getName() + ".closesCache";
CacheManager cm = CacheManager.getInstance(_uniqueName);
Cache c = Cache2kBuilder.forUnknownTypes().manager(cm).name("dummy").build();
assertSame(cm, c.getCacheManager());
cm.close();
assertTrue(c.isClosed());
}
use of org.cache2k.CacheManager in project cache2k by cache2k.
the class IllegalNamesTest method testManager.
@Test
public void testManager() {
try {
CacheManager cm = CacheManager.getInstance(IllegalNamesTest.class.getName() + "-char-" + aChar);
cm.close();
} catch (IllegalArgumentException expected) {
/* expected */
}
}
use of org.cache2k.CacheManager in project cache2k by cache2k.
the class JmxSupportTest method testManagerDestroyed.
@Test(expected = InstanceNotFoundException.class)
public void testManagerDestroyed() throws Exception {
String _name = getClass().getName() + ".testManagerDestroyed";
CacheManager m = CacheManager.getInstance(_name);
MBeanInfo i = getCacheManagerInfo(_name);
assertEquals(ManagerMXBeanImpl.class.getName(), i.getClassName());
m.close();
getCacheManagerInfo(_name);
}
use of org.cache2k.CacheManager in project cache2k by cache2k.
the class IntegrationTest method cacheCfgWithLoader.
private Cache2kConfiguration cacheCfgWithLoader() {
CacheManager mgr = CacheManager.getInstance("customizationExample");
Cache2kConfiguration cfg = Cache2kBuilder.forUnknownTypes().manager(mgr).name("withLoader").toConfiguration();
assertNull("no loader yet, default configuration returned", cfg.getLoader());
Cache2kCoreProviderImpl.augmentConfiguration(mgr, cfg);
assertNotNull("loader defined", cfg.getLoader());
return cfg;
}
use of org.cache2k.CacheManager in project cache2k by cache2k.
the class Cache2kCoreProviderImpl method getManager.
public CacheManager getManager(ClassLoader cl, String _name, boolean _default) {
CacheManager mgr;
Map<String, CacheManager> _loader2managers = loader2name2manager.get(cl);
if (_loader2managers != null) {
mgr = _loader2managers.get(_name);
if (mgr != null) {
return mgr;
}
}
synchronized (getLockObject()) {
_loader2managers = loader2name2manager.get(cl);
if (_loader2managers != null) {
mgr = _loader2managers.get(_name);
if (mgr != null) {
return mgr;
}
}
if (_loader2managers != null) {
_loader2managers = new HashMap<String, CacheManager>(_loader2managers);
} else {
_loader2managers = new HashMap<String, CacheManager>();
}
mgr = new CacheManagerImpl(this, cl, _name, _default);
_loader2managers.put(_name, mgr);
Map<ClassLoader, Map<String, CacheManager>> _copy = new WeakHashMap<ClassLoader, Map<String, CacheManager>>(loader2name2manager);
_copy.put(cl, _loader2managers);
loader2name2manager = _copy;
}
return mgr;
}
Aggregations