Example usage for org.hibernate.engine.config.spi ConfigurationService getSettings

List of usage examples for org.hibernate.engine.config.spi ConfigurationService getSettings

Introduction

In this page you can find the example usage for org.hibernate.engine.config.spi ConfigurationService getSettings.

Prototype

public Map getSettings();

Source Link

Document

Access to the complete map of config settings.

Usage

From source file:org.infinispan.test.hibernate.cache.commons.util.CacheTestUtil.java

License:LGPL

public static TestRegionFactory startRegionFactory(ServiceRegistry serviceRegistry) {
    try {/*from  w  w  w  .ja va2  s.  c o  m*/
        final ConfigurationService cfgService = serviceRegistry.getService(ConfigurationService.class);
        final Properties properties = toProperties(cfgService.getSettings());

        TestRegionFactory regionFactory = TestRegionFactoryProvider.load().create(properties);
        regionFactory.start(serviceRegistry, properties);

        return regionFactory;
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:org.infinispan.test.hibernate.cache.util.CacheTestUtil.java

License:LGPL

public static InfinispanRegionFactory startRegionFactory(ServiceRegistry serviceRegistry) {
    try {/*from  w ww.j  av a  2 s .c o  m*/
        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);
    }
}