Search in sources :

Example 1 with SessionFactoryOptionsImpl

use of org.hibernate.boot.internal.SessionFactoryOptionsImpl in project hibernate-orm by hibernate.

the class CacheTestUtil method startRegionFactory.

public static InfinispanRegionFactory startRegionFactory(ServiceRegistry serviceRegistry) {
    try {
        final ConfigurationService cfgService = serviceRegistry.getService(ConfigurationService.class);
        final Properties properties = toProperties(cfgService.getSettings());
        String factoryType = cfgService.getSetting(AvailableSettings.CACHE_REGION_FACTORY, StandardConverters.STRING);
        Class clazz = Thread.currentThread().getContextClassLoader().loadClass(factoryType);
        InfinispanRegionFactory regionFactory;
        if (clazz == InfinispanRegionFactory.class) {
            regionFactory = new TestInfinispanRegionFactory(properties);
        } else {
            if (InfinispanRegionFactory.class.isAssignableFrom(clazz)) {
                regionFactory = createRegionFactory(clazz, properties);
            } else {
                throw new IllegalArgumentException(clazz + " is not InfinispanRegionFactory");
            }
        }
        final SessionFactoryOptionsImpl sessionFactoryOptions = new SessionFactoryOptionsImpl(new SessionFactoryBuilderImpl.SessionFactoryOptionsStateStandardImpl((StandardServiceRegistry) serviceRegistry));
        regionFactory.start(sessionFactoryOptions, properties);
        return regionFactory;
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : InfinispanRegionFactory(org.hibernate.cache.infinispan.InfinispanRegionFactory) SessionFactoryOptionsImpl(org.hibernate.boot.internal.SessionFactoryOptionsImpl) Properties(java.util.Properties) TimeoutException(java.util.concurrent.TimeoutException) ConfigurationService(org.hibernate.engine.config.spi.ConfigurationService) SessionFactoryBuilderImpl(org.hibernate.boot.internal.SessionFactoryBuilderImpl) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry)

Aggregations

Properties (java.util.Properties)1 TimeoutException (java.util.concurrent.TimeoutException)1 SessionFactoryBuilderImpl (org.hibernate.boot.internal.SessionFactoryBuilderImpl)1 SessionFactoryOptionsImpl (org.hibernate.boot.internal.SessionFactoryOptionsImpl)1 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)1 InfinispanRegionFactory (org.hibernate.cache.infinispan.InfinispanRegionFactory)1 ConfigurationService (org.hibernate.engine.config.spi.ConfigurationService)1