use of org.cache2k.configuration.Cache2kConfiguration 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.configuration.Cache2kConfiguration in project cache2k by cache2k.
the class IntegrationTest method loaderByClassName.
@Test
public void loaderByClassName() {
Cache2kConfiguration cfg = cacheCfgWithLoader();
assertEquals("x.y.z", ((CustomizationSupplierByClassName) cfg.getLoader()).getClassName());
}
use of org.cache2k.configuration.Cache2kConfiguration in project cache2k by cache2k.
the class IntegrationTest method listenerByClassName.
@Test
public void listenerByClassName() {
Cache2kConfiguration cfg = cacheCfgWithLoader();
assertEquals(2, cfg.getListeners().size());
assertEquals("a.b.c", ((CustomizationSupplierByClassName) cfg.getListeners().iterator().next()).getClassName());
}
use of org.cache2k.configuration.Cache2kConfiguration in project cache2k by cache2k.
the class CacheConfigurationProviderImpl method createContext.
private ConfigurationContext createContext(ClassLoader cl, String _managerName, String _fileName_fileName) {
ParsedConfiguration pc = readManagerConfigurationWithExceptionHandling(cl, _fileName_fileName);
ConfigurationContext ctx = new ConfigurationContext();
ctx.setClassLoader(cl);
Cache2kConfiguration _defaultConfiguration = new Cache2kConfiguration();
ctx.setDefaultManagerConfiguration(_defaultConfiguration);
ctx.setDefaultManagerName(_managerName);
if (pc != null) {
ctx.setTemplates(extractTemplates(pc));
apply(ctx, pc, ctx);
if (ctx.getVersion() != null && ctx.getVersion().startsWith("1.")) {
ctx.setPredefinedSectionTypes(version1SectionTypes);
}
applyDefaultConfigurationIfPresent(ctx, pc, _defaultConfiguration);
ctx.setConfigurationPresent(true);
if (!ctx.isSkipCheckOnStartup()) {
checkCacheConfigurationOnStartup(ctx, pc);
}
}
return ctx;
}
use of org.cache2k.configuration.Cache2kConfiguration in project cache2k by cache2k.
the class CacheTypeTest method testWithCacheConfig.
/**
* getKeyType / setKeyType is not totally symmetrical, test it.
*/
@Test
public void testWithCacheConfig() throws Exception {
Cache2kConfiguration c = new Cache2kConfiguration();
c.setKeyType(String.class);
c.setValueType(new CacheTypeCapture<List<String>>() {
});
Cache2kConfiguration c2 = copyObjectViaXmlEncoder(c);
assertEquals(c.getKeyType(), c2.getKeyType());
assertEquals(c.getValueType(), c2.getValueType());
}
Aggregations