Search in sources :

Example 11 with CacheException

use of org.hibernate.cache.CacheException in project redisson by redisson.

the class RedissonRegionFactory method createRedissonClient.

protected RedissonClient createRedissonClient(Properties properties) {
    Config config = null;
    if (!properties.containsKey(REDISSON_CONFIG_PATH)) {
        config = loadConfig(RedissonRegionFactory.class.getClassLoader(), "redisson.json");
        if (config == null) {
            config = loadConfig(RedissonRegionFactory.class.getClassLoader(), "redisson.yaml");
        }
    } else {
        String configPath = ConfigurationHelper.getString(REDISSON_CONFIG_PATH, properties);
        config = loadConfig(RedissonRegionFactory.class.getClassLoader(), configPath);
        if (config == null) {
            config = loadConfig(configPath);
        }
    }
    if (config == null) {
        throw new CacheException("Unable to locate Redisson configuration");
    }
    return Redisson.create(config);
}
Also used : CacheException(org.hibernate.cache.CacheException) Config(org.redisson.config.Config)

Example 12 with CacheException

use of org.hibernate.cache.CacheException in project redisson by redisson.

the class JndiRedissonRegionFactory method createRedissonClient.

@Override
protected RedissonClient createRedissonClient(Map properties) {
    String jndiName = ConfigurationHelper.getString(JNDI_NAME, properties);
    if (jndiName == null) {
        throw new CacheException(JNDI_NAME + " property not set");
    }
    Properties jndiProperties = JndiServiceImpl.extractJndiProperties(properties);
    InitialContext context = null;
    try {
        context = new InitialContext(jndiProperties);
        return (RedissonClient) context.lookup(jndiName);
    } catch (NamingException e) {
        throw new CacheException("Unable to locate Redisson instance by name: " + jndiName, e);
    } finally {
        if (context != null) {
            try {
                context.close();
            } catch (NamingException e) {
                throw new CacheException("Unable to close JNDI context", e);
            }
        }
    }
}
Also used : RedissonClient(org.redisson.api.RedissonClient) CacheException(org.hibernate.cache.CacheException) NamingException(javax.naming.NamingException) Properties(java.util.Properties) InitialContext(javax.naming.InitialContext)

Example 13 with CacheException

use of org.hibernate.cache.CacheException in project redisson by redisson.

the class RedissonRegionFactory method createRedissonClient.

protected RedissonClient createRedissonClient(Map properties) {
    Config config = null;
    if (!properties.containsKey(REDISSON_CONFIG_PATH)) {
        config = loadConfig(RedissonRegionFactory.class.getClassLoader(), "redisson.json");
        if (config == null) {
            config = loadConfig(RedissonRegionFactory.class.getClassLoader(), "redisson.yaml");
        }
    } else {
        String configPath = ConfigurationHelper.getString(REDISSON_CONFIG_PATH, properties);
        config = loadConfig(RedissonRegionFactory.class.getClassLoader(), configPath);
        if (config == null) {
            config = loadConfig(configPath);
        }
    }
    if (config == null) {
        throw new CacheException("Unable to locate Redisson configuration");
    }
    return Redisson.create(config);
}
Also used : CacheException(org.hibernate.cache.CacheException) Config(org.redisson.config.Config) DomainDataRegionConfig(org.hibernate.cache.cfg.spi.DomainDataRegionConfig)

Example 14 with CacheException

use of org.hibernate.cache.CacheException in project uPortal by Jasig.

the class SpringBeanEhCacheRegionFactory method start.

@Override
public void start(Settings settings, Properties properties) throws CacheException {
    this.settings = settings;
    try {
        String cacheManagerBeanName = null;
        if (properties != null) {
            cacheManagerBeanName = StringUtils.trimToNull(properties.getProperty(CACHE_MANAGER_NAME));
        }
        if (cacheManagerBeanName == null) {
            throw new IllegalArgumentException("The '" + CACHE_MANAGER_NAME + "' property must be set");
        }
        logger.debug("Getting CacheManager bean named {}", cacheManagerBeanName);
        manager = CacheManager.getCacheManager(cacheManagerBeanName);
        mbeanRegistrationHelper.registerMBean(manager, properties);
    } catch (net.sf.ehcache.CacheException e) {
        throw new CacheException(e);
    }
}
Also used : CacheException(org.hibernate.cache.CacheException)

Example 15 with CacheException

use of org.hibernate.cache.CacheException in project hibernate-orm by hibernate.

the class JCacheRegionFactory method getCacheManager.

protected CacheManager getCacheManager(final Properties properties) {
    final CachingProvider cachingProvider = getCachingProvider(properties);
    final CacheManager cacheManager;
    final String cacheManagerUri = getProp(properties, CONFIG_URI);
    if (cacheManagerUri != null) {
        URI uri;
        try {
            uri = new URI(cacheManagerUri);
        } catch (URISyntaxException e) {
            throw new CacheException("Couldn't create URI from " + cacheManagerUri, e);
        }
        cacheManager = cachingProvider.getCacheManager(uri, cachingProvider.getDefaultClassLoader());
    } else {
        cacheManager = cachingProvider.getCacheManager();
    }
    return cacheManager;
}
Also used : CacheException(org.hibernate.cache.CacheException) CacheManager(javax.cache.CacheManager) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) CachingProvider(javax.cache.spi.CachingProvider)

Aggregations

CacheException (org.hibernate.cache.CacheException)28 Properties (java.util.Properties)11 URL (java.net.URL)4 Configuration (net.sf.ehcache.config.Configuration)4 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)4 CacheManager (javax.cache.CacheManager)3 Element (net.sf.ehcache.Element)3 NonStopCacheException (net.sf.ehcache.constructs.nonstop.NonStopCacheException)3 DatabaseRedisClient (com.publiccms.common.redis.DatabaseRedisClient)2 MalformedURLException (java.net.MalformedURLException)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 CachingProvider (javax.cache.spi.CachingProvider)2 InitialContext (javax.naming.InitialContext)2 NamingException (javax.naming.NamingException)2 CacheManager (net.sf.ehcache.CacheManager)2 Test (org.junit.Test)2 RedissonClient (org.redisson.api.RedissonClient)2 Config (org.redisson.config.Config)2 Enumeration (java.util.Enumeration)1