use of org.hibernate.cache.CacheException in project wildfly by wildfly.
the class InfinispanRegionFactory method createCacheManager.
@Override
protected EmbeddedCacheManager createCacheManager(Properties properties, final ServiceRegistry serviceRegistry) throws CacheException {
// Find a suitable service name to represent this session factory instance
String name = properties.getProperty(AvailableSettings.SESSION_FACTORY_NAME);
String container = properties.getProperty(CACHE_CONTAINER, DEFAULT_CACHE_CONTAINER);
HibernateSecondLevelCache.addSecondLevelCacheDependencies(properties, null);
Properties cacheSettings = new Properties();
cacheSettings.put(HibernateSecondLevelCache.CACHE_TYPE, CACHE_PRIVATE);
cacheSettings.put(HibernateSecondLevelCache.CONTAINER, container);
if (name != null) {
cacheSettings.put(HibernateSecondLevelCache.NAME, name);
}
try {
// start a private cache for non-JPA use and return the started cache.
wrapper = Notification.startCache(Classification.INFINISPAN, cacheSettings);
return (EmbeddedCacheManager) wrapper.getValue();
} catch (Exception e) {
throw new CacheException(e);
}
}
use of org.hibernate.cache.CacheException in project wildfly by wildfly.
the class InfinispanRegionFactory method createCacheManager.
@Override
protected EmbeddedCacheManager createCacheManager(Properties properties) throws CacheException {
// Find a suitable service name to represent this session factory instance
String name = properties.getProperty(AvailableSettings.SESSION_FACTORY_NAME);
String container = properties.getProperty(CACHE_CONTAINER, DEFAULT_CACHE_CONTAINER);
HibernateSecondLevelCache.addSecondLevelCacheDependencies(properties, null);
Properties cacheSettings = new Properties();
cacheSettings.put(HibernateSecondLevelCache.CACHE_TYPE, CACHE_PRIVATE);
cacheSettings.put(HibernateSecondLevelCache.CONTAINER, container);
if (name != null) {
cacheSettings.put(HibernateSecondLevelCache.NAME, name);
}
try {
// start a private cache for non-JPA use and return the started cache.
wrapper = Notification.startCache(Classification.INFINISPAN, cacheSettings);
return (EmbeddedCacheManager) wrapper.getValue();
} catch (Exception e) {
throw new CacheException(e);
}
}
use of org.hibernate.cache.CacheException in project wildfly by wildfly.
the class SharedInfinispanRegionFactory method createCacheManager.
@Override
protected EmbeddedCacheManager createCacheManager(Properties properties) {
String container = properties.getProperty(CACHE_CONTAINER, DEFAULT_CACHE_CONTAINER);
Properties cacheSettings = new Properties();
cacheSettings.put(HibernateSecondLevelCache.CONTAINER, container);
try {
// Get the (shared) cache manager for JPA application use
wrapper = Notification.startCache(Classification.INFINISPAN, cacheSettings);
return (EmbeddedCacheManager) wrapper.getValue();
} catch (Exception e) {
throw new CacheException(e);
}
}
use of org.hibernate.cache.CacheException in project PublicCMS-preview by sanluan.
the class SingletonRedisRegionFactory method start.
@Override
public void start(SessionFactoryOptions option, Properties properties) throws CacheException {
log.debug("SingletonRedisRegionFactory is starting...");
this.options = option;
try {
if (redisClient == null) {
String configurationResourceName = (String) properties.get("hibernate.redis.configurationResourceName");
if (CommonUtils.notEmpty(configurationResourceName)) {
Properties redisProperties = PropertiesLoaderUtils.loadAllProperties(configurationResourceName);
this.redisClient = new DatabaseRedisClient(RedisUtils.createJedisPool(redisProperties));
}
this.cacheTimestamper = createCacheTimestamper(redisClient, SingletonRedisRegionFactory.class.getName());
}
referenceCount.incrementAndGet();
log.info("RedisRegionFactory is started.");
} catch (Exception e) {
throw new CacheException(e);
}
}
use of org.hibernate.cache.CacheException in project hibernate-orm by hibernate.
the class SingletonEhcacheRegionFactory method resolveCacheManager.
@Override
protected CacheManager resolveCacheManager(SessionFactoryOptions settings, Map properties) {
try {
String configurationResourceName = getOptions().getServiceRegistry().getService(ConfigurationService.class).getSetting(EHCACHE_CONFIGURATION_RESOURCE_NAME, value -> value == null ? null : value.toString());
if (configurationResourceName == null || configurationResourceName.length() == 0) {
try {
REFERENCE_COUNT.incrementAndGet();
return CacheManager.create();
} catch (RuntimeException e) {
REFERENCE_COUNT.decrementAndGet();
throw e;
}
}
URL url;
try {
url = new URL(configurationResourceName);
} catch (MalformedURLException e) {
if (!configurationResourceName.startsWith("/")) {
configurationResourceName = "/" + configurationResourceName;
LOG.debugf("prepending / to %s. It should be placed in the root of the classpath rather than in a package.", configurationResourceName);
}
url = loadResource(configurationResourceName);
}
try {
REFERENCE_COUNT.incrementAndGet();
Configuration config = HibernateEhcacheUtils.loadAndCorrectConfiguration(url);
setCacheManagerNameIfNeeded(settings, config, properties);
return CacheManager.create(config);
} catch (RuntimeException e) {
REFERENCE_COUNT.decrementAndGet();
throw e;
}
} catch (net.sf.ehcache.CacheException e) {
throw new CacheException(e);
}
}
Aggregations