Search in sources :

Example 1 with DecoratedCache

use of org.infinispan.cache.impl.DecoratedCache in project camel by apache.

the class InfinispanManager method getCache.

public BasicCache<Object, Object> getCache(String cacheName) {
    if (cacheName == null) {
        cacheName = configuration.getCacheName();
    }
    LOGGER.trace("Cache[{}]", cacheName);
    BasicCache<Object, Object> cache = InfinispanUtil.getCache(cacheContainer, cacheName);
    if (configuration.hasFlags() && InfinispanUtil.isEmbedded(cache)) {
        cache = new DecoratedCache(InfinispanUtil.asAdvanced(cache), configuration.getFlags());
    }
    return cache;
}
Also used : DecoratedCache(org.infinispan.cache.impl.DecoratedCache)

Example 2 with DecoratedCache

use of org.infinispan.cache.impl.DecoratedCache in project camel by apache.

the class InfinispanConfigurationTestIT method embeddedCacheWithFlagsTest.

@Test
public void embeddedCacheWithFlagsTest() throws Exception {
    InfinispanConfiguration configuration = new InfinispanConfiguration();
    configuration.setHost("localhost");
    configuration.setCacheName("misc_cache");
    configuration.setCacheContainer(new DefaultCacheManager(true));
    configuration.setFlags(org.infinispan.context.Flag.SKIP_CACHE_LOAD, org.infinispan.context.Flag.SKIP_CACHE_STORE);
    InfinispanManager manager = new InfinispanManager(configuration);
    manager.start();
    BasicCache<Object, Object> cache = manager.getCache();
    assertNotNull(cache);
    assertTrue(cache instanceof DecoratedCache);
    DecoratedCache<Object, Object> decoratedCache = (DecoratedCache<Object, Object>) cache;
    assertTrue(decoratedCache.getFlags().contains(org.infinispan.context.Flag.SKIP_CACHE_LOAD));
    assertTrue(decoratedCache.getFlags().contains(org.infinispan.context.Flag.SKIP_CACHE_STORE));
    manager.getCacheContainer().stop();
    manager.stop();
}
Also used : DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) DecoratedCache(org.infinispan.cache.impl.DecoratedCache) Test(org.junit.Test)

Aggregations

DecoratedCache (org.infinispan.cache.impl.DecoratedCache)2 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)1 Test (org.junit.Test)1