use of javax.cache.CacheManager in project hibernate-orm by hibernate.
the class JCacheRegionFactory method resolveCacheManager.
@SuppressWarnings("WeakerAccess")
protected CacheManager resolveCacheManager(SessionFactoryOptions settings, Map properties) {
final Object explicitCacheManager = properties.get(ConfigSettings.CACHE_MANAGER);
if (explicitCacheManager != null) {
return useExplicitCacheManager(settings, explicitCacheManager);
}
final CachingProvider cachingProvider = getCachingProvider(properties);
final CacheManager cacheManager;
final String cacheManagerUri = getProp(properties, ConfigSettings.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);
}
// todo (5.3) : shouldn't this use Hibernate's AggregatedClassLoader?
cacheManager = cachingProvider.getCacheManager(uri, cachingProvider.getDefaultClassLoader());
} else {
cacheManager = cachingProvider.getCacheManager();
}
return cacheManager;
}
use of javax.cache.CacheManager in project hibernate-orm by hibernate.
the class TestHelper method buildStandardSessionFactory.
public static SessionFactoryImplementor buildStandardSessionFactory(boolean preBuildCaches, boolean prefixCaches) {
if (preBuildCaches) {
final CacheManager cacheManager = locateStandardCacheManager();
for (String regionName : entityRegionNames) {
createCache(cacheManager, regionName, prefixCaches);
}
for (String regionName : collectionRegionNames) {
createCache(cacheManager, regionName, prefixCaches);
}
createCache(cacheManager, TimestampsRegion.class.getName(), prefixCaches);
createCache(cacheManager, QueryResultsRegion.class.getName(), prefixCaches);
}
final StandardServiceRegistryBuilder ssrb = getStandardServiceRegistryBuilder();
final StandardServiceRegistry ssr = ssrb.build();
return (SessionFactoryImplementor) new MetadataSources(ssr).buildMetadata().buildSessionFactory();
}
use of javax.cache.CacheManager in project cache2k by cache2k.
the class CacheManagerTest method getNullTypeCacheRequest.
@Test(expected = NullPointerException.class)
public void getNullTypeCacheRequest() {
CacheManager cacheManager = getCacheManager();
MutableConfiguration config = new MutableConfiguration();
cacheManager.createCache("untyped-cache", config);
Cache cache = cacheManager.getCache("untyped-cache", null, null);
}
use of javax.cache.CacheManager in project cache2k by cache2k.
the class CacheManagerTest method createCache_Same.
@Test
public void createCache_Same() {
String name = "c1";
CacheManager cacheManager = getCacheManager();
try {
cacheManager.createCache(name, new MutableConfiguration());
Cache cache1 = cacheManager.getCache(name);
cacheManager.createCache(name, new MutableConfiguration());
Cache cache2 = cacheManager.getCache(name);
fail();
} catch (CacheException exception) {
// expected
}
}
use of javax.cache.CacheManager in project cache2k by cache2k.
the class CacheManagerTest method close.
@Test
public void close() {
CacheManager cacheManager = getCacheManager();
assertFalse(cacheManager.isClosed());
cacheManager.close();
assertTrue(cacheManager.isClosed());
}
Aggregations