use of org.infinispan.configuration.parsing.ParserRegistry in project hibernate-orm by hibernate.
the class InfinispanRegionFactoryTestCase method testTimestampValidation.
@Test(expected = CacheException.class)
public void testTimestampValidation() {
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
Properties p = createProperties();
InputStream configStream = FileLookupFactory.newInstance().lookupFile(InfinispanRegionFactory.DEF_INFINISPAN_CONFIG_RESOURCE, getClass().getClassLoader());
ConfigurationBuilderHolder cbh = new ParserRegistry().parse(configStream);
DefaultCacheManager manager = new DefaultCacheManager(cbh, true);
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().cacheMode(CacheMode.INVALIDATION_SYNC);
manager.defineConfiguration(DEF_TIMESTAMPS_RESOURCE, builder.build());
try {
InfinispanRegionFactory factory = createRegionFactory(manager, p, null);
factory.start(CacheTestUtil.sfOptionsForStart(), p);
TimestampsRegionImpl region = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
fail("Should have failed saying that invalidation is not allowed for timestamp caches.");
} finally {
TestingUtil.killCacheManagers(manager);
}
}
use of org.infinispan.configuration.parsing.ParserRegistry in project hibernate-orm by hibernate.
the class InfinispanRegionFactory method loadConfiguration.
private ConfigurationBuilderHolder loadConfiguration(ServiceRegistry serviceRegistry, String configFile) {
final FileLookup fileLookup = FileLookupFactory.newInstance();
final ClassLoader infinispanClassLoader = InfinispanRegionFactory.class.getClassLoader();
return serviceRegistry.getService(ClassLoaderService.class).workWithClassLoader(new ClassLoaderService.Work<ConfigurationBuilderHolder>() {
@Override
public ConfigurationBuilderHolder doWork(ClassLoader classLoader) {
InputStream is = null;
try {
is = fileLookup.lookupFile(configFile, classLoader);
if (is == null) {
// when it's not a user-provided configuration file, it might be a default configuration file,
// and if that's included in [this] module might not be visible to the ClassLoaderService:
classLoader = infinispanClassLoader;
// This time use lookupFile*Strict* so to provide an exception if we can't find it yet:
is = FileLookupFactory.newInstance().lookupFileStrict(configFile, classLoader);
}
final ParserRegistry parserRegistry = new ParserRegistry(infinispanClassLoader);
final ConfigurationBuilderHolder holder = parseWithOverridenClassLoader(parserRegistry, is, infinispanClassLoader);
return holder;
} catch (IOException e) {
throw log.unableToCreateCacheManager(e);
} finally {
Util.close(is);
}
}
});
}
Aggregations