Search in sources :

Example 1 with Cache2kConfiguration

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;
}
Also used : Cache2kConfiguration(org.cache2k.configuration.Cache2kConfiguration) CacheManager(org.cache2k.CacheManager)

Example 2 with Cache2kConfiguration

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());
}
Also used : Cache2kConfiguration(org.cache2k.configuration.Cache2kConfiguration) Test(org.junit.Test)

Example 3 with Cache2kConfiguration

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());
}
Also used : Cache2kConfiguration(org.cache2k.configuration.Cache2kConfiguration) Test(org.junit.Test)

Example 4 with Cache2kConfiguration

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;
}
Also used : Cache2kConfiguration(org.cache2k.configuration.Cache2kConfiguration)

Example 5 with Cache2kConfiguration

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());
}
Also used : Cache2kConfiguration(org.cache2k.configuration.Cache2kConfiguration) List(java.util.List) Test(org.junit.Test)

Aggregations

Cache2kConfiguration (org.cache2k.configuration.Cache2kConfiguration)5 Test (org.junit.Test)3 List (java.util.List)1 CacheManager (org.cache2k.CacheManager)1