* @return cacheManager
* @throws Exception
*/
private EmbeddedCacheManager getSharedCacheManager(InputStream configStream) throws Exception {
if (cacheManager == null) {
EmbeddedCacheManager cacheManager = new DefaultCacheManager(configStream, false);
GlobalConfiguration globalConfigFromXml = cacheManager.getCacheManagerConfiguration();
GlobalConfigurationBuilder globalConfigBuilder = new GlobalConfigurationBuilder();
globalConfigBuilder.read(globalConfigFromXml);
Configuration configFromXml = cacheManager.getDefaultCacheConfiguration();
ConfigurationBuilder configBuilder = new ConfigurationBuilder().read(configFromXml);
// Configure transactionManagerLookup programmatically if not provided in configuration
TransactionManagerLookup tmLookup = configFromXml.transaction().transactionManagerLookup();
if (tmLookup == null) {
tmLookup = getTransactionManagerLookup();
configBuilder.transaction().transactionManagerLookup(tmLookup);
}
log.debug("Infinispan transaction manager lookup: " + tmLookup);
// If we don't want structure cache entries to expire, we need to configure infinite lifespan and keep original
// lifespan value, which will be send to tree api
if (skipExpirationOfStructureCacheEntries) {
cacheLifespanOfLeafNodes = configFromXml.expiration().lifespan();
configBuilder.expiration().lifespan(-1);
log.debug("Expiration of structure cache entries is disabled. Leaf nodes will use expiration "
+ cacheLifespanOfLeafNodes);
}
cacheManager = new DefaultCacheManager(globalConfigBuilder.build(), configBuilder.build(), true);
this.cacheManager = cacheManager;
}
return cacheManager;
}