use of org.infinispan.manager.DefaultCacheManager in project galley by Commonjava.
the class RoutingCacheProviderWrapperTest method prepare.
@Before
public void prepare() throws Exception {
final File cacheDir = temp.newFolder();
partylineFac = new PartyLineCacheProviderFactory(cacheDir);
SimpleCacheInstance<String, String> cacheInstance = new SimpleCacheInstance<>("test", new DefaultCacheManager().getCache());
fastLocalFac = new FastLocalCacheProviderFactory(cacheDir, temp.newFolder(), cacheInstance, Executors.newFixedThreadPool(5));
}
use of org.infinispan.manager.DefaultCacheManager in project galley by Commonjava.
the class NFSOwnerCacheProducer method getCacheMgr.
public EmbeddedCacheManager getCacheMgr() {
final EmbeddedCacheManager cacheManager = new DefaultCacheManager(new GlobalConfigurationBuilder().globalJmxStatistics().jmxDomain("org.commonjava.maven.galley").build());
// Want to enable dead lock check as lock will be used in FastLocalCacheProvider
// and also set transaction mode to PESSIMISTIC with DummyTransactionManger.
final Configuration configuration = new ConfigurationBuilder().eviction().strategy(EvictionStrategy.LRU).size(1000).type(EvictionType.COUNT).deadlockDetection().spinDuration(10, TimeUnit.SECONDS).enable().transaction().transactionManagerLookup(new DummyTransactionManagerLookup()).lockingMode(LockingMode.PESSIMISTIC).build();
cacheManager.defineConfiguration(CACHE_NAME, configuration);
return cacheManager;
}
use of org.infinispan.manager.DefaultCacheManager in project sling by apache.
the class CacheManagerServiceImpl method activate.
@Activate
public void activate(Map<String, Object> properties) throws FileNotFoundException, IOException {
String config = toString(properties.get(CACHE_CONFIG), DEFAULT_CACHE_CONFIG);
File configFile = new File(config);
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
if (configFile.exists()) {
LOGGER.info("Configuring Cache from {} ", configFile.getAbsolutePath());
InputStream in = null;
try {
in = processConfig(new FileInputStream(configFile), properties);
cacheManager = new DefaultCacheManager(in);
} finally {
if (in != null) {
in.close();
}
}
} else {
LOGGER.info("Configuring Cache from Classpath Default {} ", CONFIG_PATH);
InputStream in = processConfig(this.getClass().getClassLoader().getResourceAsStream(CONFIG_PATH), properties);
if (in == null) {
throw new IOException("Unable to open config at classpath location " + CONFIG_PATH);
}
cacheManager = new DefaultCacheManager(in);
in.close();
}
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
final WeakReference<CacheManagerServiceImpl> ref = new WeakReference<CacheManagerServiceImpl>(this);
/*
* Add in a shutdown hook, for safety
*/
Runtime.getRuntime().addShutdownHook(new Thread() {
/*
* (non-Javadoc)
*
* @see java.lang.Thread#run()
*/
@Override
public void run() {
try {
CacheManagerServiceImpl cm = ref.get();
if (cm != null) {
cm.deactivate();
}
} catch (Throwable t) {
LOGGER.debug(t.getMessage(), t);
}
}
});
// JMX Registration is performed by configuration
}
use of org.infinispan.manager.DefaultCacheManager in project hibernate-orm by hibernate.
the class TestInfinispanRegionFactory method createCacheManager.
@Override
protected EmbeddedCacheManager createCacheManager(ConfigurationBuilderHolder holder) {
// If the cache manager has been provided by calling setCacheManager, don't create a new one
EmbeddedCacheManager cacheManager = getCacheManager();
if (cacheManager != null) {
return cacheManager;
}
amendConfiguration(holder);
cacheManager = new DefaultCacheManager(holder, true);
if (timeService != null) {
cacheManager.getGlobalComponentRegistry().registerComponent(timeService, TimeService.class);
cacheManager.getGlobalComponentRegistry().rewire();
}
return cacheManager;
}
use of org.infinispan.manager.DefaultCacheManager in project camel by apache.
the class InfinispanTestSupport method setUp.
@Override
@Before
public void setUp() throws Exception {
basicCacheContainer = new DefaultCacheManager();
basicCacheContainer.start();
super.setUp();
}
Aggregations