use of net.sf.ehcache.config.Configuration in project cxf by apache.
the class EHCacheUtilsTest method testUseGlobalManager.
@Test
public void testUseGlobalManager() {
Bus bus = BusFactory.getThreadDefaultBus();
Configuration conf = ConfigurationFactory.parseConfiguration(EHCacheManagerHolder.class.getResource("/cxf-test-ehcache.xml"));
conf.setName("myGlobalConfig");
CacheManager.newInstance(conf);
CacheManager manager = EHCacheUtils.getCacheManager(bus, EHCacheManagerHolder.class.getResource("/cxf-test-ehcache.xml"));
assertFalse(manager.getName().equals("myGlobalConfig"));
EHCacheManagerHolder.releaseCacheManger(manager);
assertEquals(Status.STATUS_SHUTDOWN, manager.getStatus());
bus.setProperty(EHCacheUtils.GLOBAL_EHCACHE_MANAGER_NAME, "myGlobalConfig");
manager = EHCacheUtils.getCacheManager(bus, EHCacheManagerHolder.class.getResource("/cxf-test-ehcache.xml"));
assertEquals("myGlobalConfig", manager.getName());
EHCacheManagerHolder.releaseCacheManger(manager);
assertEquals(Status.STATUS_ALIVE, manager.getStatus());
manager.shutdown();
assertEquals(Status.STATUS_SHUTDOWN, manager.getStatus());
bus.setProperty(EHCacheUtils.GLOBAL_EHCACHE_MANAGER_NAME, "myGlobalConfigXXX");
manager = EHCacheUtils.getCacheManager(bus, EHCacheManagerHolder.class.getResource("/cxf-test-ehcache.xml"));
assertFalse(manager.getName().equals("myGlobalConfig"));
EHCacheManagerHolder.releaseCacheManger(manager);
assertEquals(Status.STATUS_SHUTDOWN, manager.getStatus());
}
use of net.sf.ehcache.config.Configuration in project cxf by apache.
the class EHCacheXKMSClientCache method createCache.
private void createCache(String configFile, Bus cxfBus) {
if (cxfBus == null) {
cxfBus = BusFactory.getThreadDefaultBus(true);
}
URL configFileURL = null;
try {
configFileURL = ClassLoaderUtils.getResource(configFile, EHCacheXKMSClientCache.class);
} catch (Exception ex) {
// ignore
}
if (configFileURL == null) {
cacheManager = EHCacheUtil.createCacheManager();
} else {
Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL);
if (cxfBus != null) {
conf.setName(cxfBus.getId());
DiskStoreConfiguration dsc = conf.getDiskStoreConfiguration();
if (dsc != null && "java.io.tmpdir".equals(dsc.getOriginalPath())) {
String path = conf.getDiskStoreConfiguration().getPath() + File.separator + cxfBus.getId();
conf.getDiskStoreConfiguration().setPath(path);
}
}
cacheManager = EHCacheUtil.createCacheManager(conf);
}
CacheConfiguration cc = EHCacheUtil.getCacheConfiguration(CACHE_KEY, cacheManager);
Ehcache newCache = new Cache(cc);
cache = cacheManager.addCacheIfAbsent(newCache);
}
use of net.sf.ehcache.config.Configuration in project cxf by apache.
the class EHCacheTokenReplayCache method createCache.
private void createCache(String configFile, Bus bus) {
if (bus == null) {
bus = BusFactory.getThreadDefaultBus(true);
}
URL configFileURL = null;
try {
configFileURL = ResourceUtils.getClasspathResourceURL(configFile, EHCacheTokenReplayCache.class, bus);
} catch (Exception ex) {
// ignore
}
if (configFileURL == null) {
cacheManager = EHCacheUtil.createCacheManager();
} else {
Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL);
if (bus != null) {
conf.setName(bus.getId());
DiskStoreConfiguration dsc = conf.getDiskStoreConfiguration();
if (dsc != null && "java.io.tmpdir".equals(dsc.getOriginalPath())) {
String path = conf.getDiskStoreConfiguration().getPath() + File.separator + bus.getId();
conf.getDiskStoreConfiguration().setPath(path);
}
}
cacheManager = EHCacheUtil.createCacheManager(conf);
}
CacheConfiguration cc = EHCacheUtil.getCacheConfiguration(CACHE_KEY, cacheManager);
Ehcache newCache = new Cache(cc);
cache = cacheManager.addCacheIfAbsent(newCache);
}
use of net.sf.ehcache.config.Configuration in project ff4j by ff4j.
the class PropertyStoreEhCacheTest method initWithConfig.
@Test
public void initWithConfig() {
Configuration managerConfiguration = new Configuration();
managerConfiguration.name("config");
PropertyStoreEhCache storeEHcache = new PropertyStoreEhCache(managerConfiguration);
Assert.assertNotNull(storeEHcache);
}
use of net.sf.ehcache.config.Configuration in project ff4j by ff4j.
the class FeatureStoreTerracottaTestIT method initStore.
/**
* {@inheritDoc}
*/
@Override
protected FeatureStore initStore() {
// Configuration to wirk with Terracotta
Configuration managerConfiguration = new Configuration();
managerConfiguration.name("config").terracotta(new TerracottaClientConfiguration().url(TERRACOTTA_URL)).defaultCache(new CacheConfiguration().maxBytesLocalHeap(128, MemoryUnit.MEGABYTES).terracotta(new TerracottaConfiguration())).cache(new CacheConfiguration().name(FF4jEhCacheWrapper.CACHENAME_FEATURES).maxBytesLocalHeap(128, MemoryUnit.MEGABYTES).terracotta(new TerracottaConfiguration()));
FeatureStoreEhCache ehcacheStore = new FeatureStoreEhCache(managerConfiguration);
ehcacheStore.importFeaturesFromXmlFile("ff4j.xml");
return ehcacheStore;
}
Aggregations