Java 类org.hibernate.cfg.Settings 实例源码

项目:lams    文件:SessionFactoryImpl.java   
SessionBuilderImpl(SessionFactoryImpl sessionFactory) {
    this.sessionFactory = sessionFactory;
    this.sessionOwner = null;
    final Settings settings = sessionFactory.settings;

    // set up default builder values...
    this.interceptor = sessionFactory.getInterceptor();
    this.connectionReleaseMode = settings.getConnectionReleaseMode();
    this.autoClose = settings.isAutoCloseSessionEnabled();
    this.flushBeforeCompletion = settings.isFlushBeforeCompletionEnabled();

    if ( sessionFactory.getCurrentTenantIdentifierResolver() != null ) {
        tenantIdentifier = sessionFactory.getCurrentTenantIdentifierResolver().resolveCurrentTenantIdentifier();
    }

    listeners = settings.getBaselineSessionEventsListenerBuilder().buildBaselineList();
}
项目:lams    文件:StandardQueryCache.java   
/**
 * Constructs a StandardQueryCache instance
 *
 * @param settings The SessionFactory settings.
 * @param props Any properties
 * @param updateTimestampsCache The update-timestamps cache to use.
 * @param regionName The base query cache region name
 */
public StandardQueryCache(
        final Settings settings,
        final Properties props,
        final UpdateTimestampsCache updateTimestampsCache,
        final String regionName) {
    String regionNameToUse = regionName;
    if ( regionNameToUse == null ) {
        regionNameToUse = StandardQueryCache.class.getName();
    }
    final String prefix = settings.getCacheRegionPrefix();
    if ( prefix != null ) {
        regionNameToUse = prefix + '.' + regionNameToUse;
    }
    LOG.startingQueryCache( regionNameToUse );

    this.cacheRegion = settings.getRegionFactory().buildQueryResultsRegion( regionNameToUse, props );
    this.updateTimestampsCache = updateTimestampsCache;
}
项目:cacheonix-core    文件:StandardQueryCache.java   
public StandardQueryCache(
        final Settings settings, 
        final Properties props, 
        final UpdateTimestampsCache updateTimestampsCache, 
        String regionName) throws HibernateException {
    if ( regionName == null ) {
        regionName = StandardQueryCache.class.getName();
    }
    String prefix = settings.getCacheRegionPrefix();
    if ( prefix != null ) {
        regionName = prefix + '.' + regionName;
    }
    log.info( "starting query cache at region: " + regionName );

    this.queryCache = settings.getCacheProvider().buildCache(regionName, props);
    this.updateTimestampsCache = updateTimestampsCache;
    this.regionName = regionName;
}
项目:hazelcast-archive    文件:CacheProviderHazelcastAccessor.java   
public HazelcastInstance getHazelcastInstance(Settings settings) {
    Object providerObject = null;
    try {
        Method getCacheProviderMethod = Settings.class.getMethod(METHOD_GET_CACHE_PROVIDER);
        providerObject = getCacheProviderMethod.invoke(settings);
    } catch (Exception e) {
        logger.log(Level.SEVERE, e.getMessage(), e);
        return null;
    }
    if (providerObject == null) {
        logger.log(Level.SEVERE, "Hibernate 2nd level cache has not been enabled!");
        return null;
    }
    final CacheProvider provider = (CacheProvider) providerObject;
    if (provider instanceof HazelcastCacheProvider) {
        return ((HazelcastCacheProvider) provider).getHazelcastInstance();
    }
    logger.log(Level.WARNING, "Current 2nd level cache implementation is not HazelcastCacheProvider!");
    return null;
}
项目:hazelcast-archive    文件:RegionFactoryHazelcastAccessor.java   
public HazelcastInstance getHazelcastInstance(Settings settings) {
    final RegionFactory rf = settings.getRegionFactory();
    if (rf == null) {
        logger.log(Level.SEVERE, "Hibernate 2nd level cache has not been enabled!");
        return null;
    }
    if (rf instanceof RegionFactoryCacheProviderBridge) {
        final CacheProvider provider = ((RegionFactoryCacheProviderBridge) rf).getCacheProvider();
        if (provider instanceof HazelcastCacheProvider) {
            return ((HazelcastCacheProvider) provider).getHazelcastInstance();
        }
        logger.log(Level.WARNING, "Current 2nd level cache implementation is not HazelcastCacheProvider!");
    } else if (rf instanceof HazelcastCacheRegionFactory) {
        return ((HazelcastCacheRegionFactory) rf).getHazelcastInstance();
    } else {
        logger.log(Level.WARNING, "Current 2nd level cache implementation is not HazelcastCacheRegionFactory!");
    }
    return null;
}
项目:hibernate-dynamic-dialects    文件:SessionFactoryImpl.java   
SessionBuilderImpl(SessionFactoryImpl sessionFactory) {
    this.sessionFactory = sessionFactory;
    this.sessionOwner = null;
    final Settings settings = sessionFactory.settings;

    // set up default builder values...
    this.interceptor = sessionFactory.getInterceptor();
    this.connectionReleaseMode = settings.getConnectionReleaseMode();
    this.autoClose = settings.isAutoCloseSessionEnabled();
    this.flushBeforeCompletion = settings
            .isFlushBeforeCompletionEnabled();

    if (sessionFactory.getCurrentTenantIdentifierResolver() != null) {
        tenantIdentifier = sessionFactory
                .getCurrentTenantIdentifierResolver()
                .resolveCurrentTenantIdentifier();
    }
}
项目:hibernate4-memcached    文件:Hibernate4MemcachedRegionFactory.java   
HibernateCacheTimestamper populateTimestamper(Settings settings, OverridableReadOnlyProperties properties) {
    String timestamperClazzName = properties.getProperty(TIMESTAMPER_PROPERTY_KEY,
            DEFAULT_TIMESTAMPER_CLASS.getName());

    HibernateCacheTimestamper timestamper;
    try {
        Class<?> clazz = Class.forName(timestamperClazzName);
        timestamper = (HibernateCacheTimestamper) clazz.newInstance();
    } catch (Exception e) {
        throw new IllegalStateException(e.getMessage(), e);
    }

    timestamper.setSettings(settings);
    timestamper.setProperties(properties);
    timestamper.setMemcachedAdapter(memcachedAdapter);
    timestamper.init();
    return timestamper;
}
项目:health-and-care-developer-network    文件:CacheProviderHazelcastAccessor.java   
public HazelcastInstance getHazelcastInstance(Settings settings) {
    Object providerObject = null;
    try {
        Method getCacheProviderMethod = Settings.class.getMethod(METHOD_GET_CACHE_PROVIDER);
        providerObject = getCacheProviderMethod.invoke(settings);
    } catch (Exception e) {
        logger.log(Level.SEVERE, e.getMessage(), e);
        return null;
    }
    if (providerObject == null) {
        logger.log(Level.SEVERE, "Hibernate 2nd level cache has not been enabled!");
        return null;
    }
    final CacheProvider provider = (CacheProvider) providerObject;
    if (provider instanceof HazelcastCacheProvider) {
        return ((HazelcastCacheProvider) provider).getHazelcastInstance();
    }
    logger.log(Level.WARNING, "Current 2nd level cache implementation is not HazelcastCacheProvider!");
    return null;
}
项目:health-and-care-developer-network    文件:RegionFactoryHazelcastAccessor.java   
public HazelcastInstance getHazelcastInstance(Settings settings) {
    final RegionFactory rf = settings.getRegionFactory();
    if (rf == null) {
        logger.log(Level.SEVERE, "Hibernate 2nd level cache has not been enabled!");
        return null;
    }
    if (rf instanceof RegionFactoryCacheProviderBridge) {
        final CacheProvider provider = ((RegionFactoryCacheProviderBridge) rf).getCacheProvider();
        if (provider instanceof HazelcastCacheProvider) {
            return ((HazelcastCacheProvider) provider).getHazelcastInstance();
        }
        logger.log(Level.WARNING, "Current 2nd level cache implementation is not HazelcastCacheProvider!");
    } else if (rf instanceof AbstractHazelcastCacheRegionFactory) {
        return ((AbstractHazelcastCacheRegionFactory) rf).getHazelcastInstance();
    } else {
        logger.log(Level.WARNING, "Current 2nd level cache implementation is not HazelcastCacheRegionFactory!");
    }
    return null;
}
项目:lams    文件:LocalSessionFactoryBuilder.java   
@Override
public Settings buildSettings(Properties props, ServiceRegistry serviceRegistry) throws HibernateException {
    Settings settings = super.buildSettings(props, serviceRegistry);
    if (this.cacheRegionFactory != null) {
        try {
            Method setRegionFactory = Settings.class.getDeclaredMethod("setRegionFactory", RegionFactory.class);
            setRegionFactory.setAccessible(true);
            setRegionFactory.invoke(settings, this.cacheRegionFactory);
        }
        catch (Exception ex) {
            throw new IllegalStateException("Failed to invoke Hibernate's setRegionFactory method", ex);
        }
    }
    return settings;
}
项目:lams    文件:UpdateTimestampsCache.java   
/**
 * Constructs an UpdateTimestampsCache.
 *
 * @param settings The SessionFactory settings
 * @param props Any properties
 * @param factory The SessionFactory
 */
public UpdateTimestampsCache(Settings settings, Properties props, final SessionFactoryImplementor factory) {
    this.factory = factory;
    final String prefix = settings.getCacheRegionPrefix();
    final String regionName = prefix == null ? REGION_NAME : prefix + '.' + REGION_NAME;

    LOG.startingUpdateTimestampsCache( regionName );
    this.region = settings.getRegionFactory().buildTimestampsRegion( regionName, props );
}
项目:lams    文件:StandardQueryCacheFactory.java   
@Override
public QueryCache getQueryCache(
        final String regionName,
        final UpdateTimestampsCache updateTimestampsCache,
        final Settings settings,
        final Properties props) throws HibernateException {
    return new StandardQueryCache(settings, props, updateTimestampsCache, regionName);
}
项目:spring4-understanding    文件:LocalSessionFactoryBuilder.java   
@Override
public Settings buildSettings(Properties props, ServiceRegistry serviceRegistry) throws HibernateException {
    Settings settings = super.buildSettings(props, serviceRegistry);
    if (this.cacheRegionFactory != null) {
        try {
            Method setRegionFactory = Settings.class.getDeclaredMethod("setRegionFactory", RegionFactory.class);
            setRegionFactory.setAccessible(true);
            setRegionFactory.invoke(settings, this.cacheRegionFactory);
        }
        catch (Exception ex) {
            throw new IllegalStateException("Failed to invoke Hibernate's setRegionFactory method", ex);
        }
    }
    return settings;
}
项目:jhipster-ribbon-hystrix    文件:_HazelcastCacheRegionFactory.java   
public void start(Settings settings, Properties properties) throws CacheException {
    // Do nothing the hazelcast hazelcastInstance is injected
    log.info("Starting up {}", getClass().getSimpleName());

    if (hazelcastInstance == null) {
        throw new IllegalArgumentException("Hazelcast hazelcastInstance must not be null");
    }
    cleanupService = new CleanupService(hazelcastInstance.getName());
}
项目:Thesis-JHipster    文件:_HazelcastCacheRegionFactory.java   
public void start(Settings settings, Properties properties) throws CacheException {
    // Do nothing the hazelcast hazelcastInstance is injected
    log.info("Starting up {}", getClass().getSimpleName());

    if (hazelcastInstance == null) {
        throw new IllegalArgumentException("Hazelcast hazelcastInstance must not be null");
    }
    cleanupService = new CleanupService(hazelcastInstance.getName());
}
项目:hazelcast-hibernate    文件:AbstractHazelcastCacheRegionFactory.java   
public void start(final Settings settings, final Properties properties) throws CacheException {
    log.info("Starting up " + getClass().getSimpleName());
    if (instance == null || !instance.getLifecycleService().isRunning()) {
        instanceLoader = HazelcastInstanceFactory.createInstanceLoader(properties);
        instance = instanceLoader.loadInstance();
    }
    cleanupService = new CleanupService(instance.getName());
}
项目:hazelcast-hibernate    文件:HazelcastAccessor.java   
/**
 * Tries to extract <code>HazelcastInstance</code> from <code>SessionFactoryImplementor</code>.
 *
 * @param sessionFactory Hibernate <code>SessionFactory</code> to extract settings from
 * @return currently used <code>HazelcastInstance</code> or null if an error occurs.
 */
public static HazelcastInstance getHazelcastInstance(final SessionFactoryImplementor sessionFactory) {
    final Settings settings = sessionFactory.getSettings();
    final RegionFactory rf = settings.getRegionFactory();
    if (rf instanceof AbstractHazelcastCacheRegionFactory) {
        return ((AbstractHazelcastCacheRegionFactory) rf).getHazelcastInstance();
    } else {
        LOGGER.warning("Current 2nd level cache implementation is not HazelcastCacheRegionFactory!");
    }
    return null;
}
项目:hazelcast-hibernate    文件:AbstractHazelcastCacheRegionFactory.java   
@Override
public void start(final Settings settings, final Properties properties) throws CacheException {
    logger.info("Starting up " + getClass().getSimpleName());
    if (instance == null || !instance.getLifecycleService().isRunning()) {
        instanceLoader = HazelcastInstanceFactory.createInstanceLoader(properties);
        instance = instanceLoader.loadInstance();
    }
    cleanupService = new CleanupService(instance.getName());
}
项目:hazelcast-hibernate    文件:HazelcastAccessor.java   
/**
 * Tries to extract <code>HazelcastInstance</code> from <code>SessionFactoryImplementor</code>.
 *
 * @param sessionFactory Hibernate <code>SessionFactory</code> to extract settings from
 * @return currently used <code>HazelcastInstance</code> or null if an error occurs.
 */
public static HazelcastInstance getHazelcastInstance(final SessionFactoryImplementor sessionFactory) {
    final Settings settings = sessionFactory.getSettings();
    final RegionFactory rf = settings.getRegionFactory();
    if (rf instanceof AbstractHazelcastCacheRegionFactory) {
        return ((AbstractHazelcastCacheRegionFactory) rf).getHazelcastInstance();
    } else {
        LOGGER.warning("Current 2nd level cache implementation is not HazelcastCacheRegionFactory!");
    }
    return null;
}
项目:cacheonix-core    文件:SchemaExport.java   
/**
 * Create a schema exporter for the given Configuration
 * and given settings
 */
public SchemaExport(Configuration cfg, Settings settings) throws HibernateException {
    dialect = settings.getDialect();
    connectionHelper = new SuppliedConnectionProviderConnectionHelper(
            settings.getConnectionProvider()
    );
    dropSQL = cfg.generateDropSchemaScript( dialect );
    createSQL = cfg.generateSchemaCreationScript( dialect );
    format = settings.isFormatSqlEnabled();
}
项目:cacheonix-core    文件:SchemaUpdate.java   
public SchemaUpdate(Configuration cfg, Settings settings) throws HibernateException {
    this.configuration = cfg;
    dialect = settings.getDialect();
    connectionHelper = new SuppliedConnectionProviderConnectionHelper(
            settings.getConnectionProvider()
    );
    exceptions = new ArrayList();
}
项目:cacheonix-core    文件:SchemaValidator.java   
public SchemaValidator(Configuration cfg, Settings settings) throws HibernateException {
    this.configuration = cfg;
    dialect = settings.getDialect();
    connectionHelper = new SuppliedConnectionProviderConnectionHelper(
            settings.getConnectionProvider()
    );
}
项目:cacheonix-core    文件:StandardQueryCacheFactory.java   
public QueryCache getQueryCache(
        final String regionName,
        final UpdateTimestampsCache updateTimestampsCache,
        final Settings settings,
        final Properties props) 
throws HibernateException {
    return new StandardQueryCache(settings, props, updateTimestampsCache, regionName);
}
项目:ignite    文件:HibernateRegionFactory.java   
/** {@inheritDoc} */
@Override public void start(Settings settings, Properties props) throws CacheException {
    String accessType = props.getProperty(DFLT_ACCESS_TYPE_PROPERTY, NONSTRICT_READ_WRITE.name());

    dfltAccessType = AccessType.valueOf(accessType);

    accessStgyFactory.start(props);
}
项目:ithings-demo    文件:HazelcastCacheRegionFactory.java   
public void start(final Settings settings, final Properties properties) throws CacheException {
    // Do nothing the hazelcast hazelcastInstance is injected
    log.info("Starting up {}", getClass().getSimpleName());

    if (hazelcastInstance == null) {
        throw new IllegalArgumentException("Hazelcast hazelcastInstance must not be null");
    }
    cleanupService = new CleanupService(hazelcastInstance.getName());
}
项目:hazelcast-archive    文件:HazelcastCacheRegionFactory.java   
public void start(final Settings settings, final Properties properties) throws CacheException {
    LOG.log(Level.INFO, "Starting up HazelcastCacheRegionFactory...");
    if (instance == null || !instance.getLifecycleService().isRunning()) {
        instanceLoader = HazelcastInstanceFactory.createInstanceLoader(properties);
        instance = instanceLoader.loadInstance();
    }
}
项目:hibernate4-memcached    文件:MemcachedRegion.java   
public MemcachedRegion(CacheNamespace cacheNamespace, OverridableReadOnlyProperties properties, CacheDataDescription metadata, Settings settings,
                       MemcachedAdapter memcachedAdapter, HibernateCacheTimestamper hibernateCacheTimestamper) {
    this.cacheNamespace = cacheNamespace;
    this.properties = properties;
    this.metadata = metadata;
    this.settings = settings;
    this.memcachedAdapter = memcachedAdapter;
    this.hibernateCacheTimestamper = hibernateCacheTimestamper;
}
项目:hibernate4-memcached    文件:NaturalIdMemcachedRegion.java   
public NaturalIdMemcachedRegion(String regionName, OverridableReadOnlyProperties properties,
                                CacheDataDescription metadata, Settings settings,
                                MemcachedAdapter memcachedAdapter,
                                HibernateCacheTimestamper hibernateCacheTimestamper) {
    super(new CacheNamespace(regionName, true), properties, metadata, settings, memcachedAdapter,
          hibernateCacheTimestamper);
}
项目:hibernate4-memcached    文件:Hibernate4MemcachedRegionFactory.java   
@Override
public void start(Settings settings, Properties properties) throws CacheException {
    log.debug("# start Hibernate4MemcachedRegionFactory.");

    this.settings = settings;
    cacheProviderConfigProperties = populateCacheProviderConfigProperties(properties);
    OverridableReadOnlyProperties mergedConfigProperties = new OverridableReadOnlyPropertiesImpl(properties,
            cacheProviderConfigProperties);
    memcachedAdapter = populateMemcachedProvider(mergedConfigProperties);
    hibernateCacheTimestamper = populateTimestamper(settings, mergedConfigProperties);
}
项目:hibernate4-memcached    文件:Hibernate4MemcachedRegionFactoryTest.java   
@Test
public void populateTimestamper_default() throws Exception {
    Properties properties = new Properties();
    Settings settings = new TestingSettingsBuilder().build();

    HibernateCacheTimestamper timestamper = regionFactory.populateTimestamper(settings,
            new OverridableReadOnlyPropertiesImpl(properties));

    assertThat(timestamper).isExactlyInstanceOf(Hibernate4MemcachedRegionFactory.DEFAULT_TIMESTAMPER_CLASS);
}
项目:hibernate4-memcached    文件:Hibernate4MemcachedRegionFactoryTest.java   
@Test
public void populateTimestamper() throws Exception {
    Properties properties = new Properties();
    properties.setProperty(Hibernate4MemcachedRegionFactory.TIMESTAMPER_PROPERTY_KEY,
            FakeHibernateCacheTimestamper.class.getName());

    Settings settings = new TestingSettingsBuilder().build();

    HibernateCacheTimestamper timestamper = regionFactory.populateTimestamper(settings,
            new OverridableReadOnlyPropertiesImpl(properties));

    assertThat(timestamper).isExactlyInstanceOf(FakeHibernateCacheTimestamper.class);
    assertThat(((FakeHibernateCacheTimestamper) timestamper).isInitCalled()).isTrue();
}
项目:hibernate4-memcached    文件:MemcachedRegionAccessStrategyTest.java   
@Test
public void putFromLoad_without_minimalPutOverride() throws Exception {
    Settings settings = new TestingSettingsBuilder().setField("minimalPutsEnabled", true).build();
    when(generalDataMemcachedRegion.getSettings()).thenReturn(settings);

    memcachedRegionAccessStrategy.putFromLoad("books#1", "book 1", 1L, "version object");

    verify(memcachedRegionAccessStrategy).putFromLoad("books#1", "book 1", 1L, "version object", true);
}
项目:hibernate4-memcached    文件:MemcachedRegionAccessStrategyTest.java   
@Test
public void isMinimalPutsEnabled_true() throws Exception {
    Settings settings = new TestingSettingsBuilder().setField("minimalPutsEnabled", true).build();
    when(generalDataMemcachedRegion.getSettings()).thenReturn(settings);

    assertThat(memcachedRegionAccessStrategy.isMinimalPutsEnabled()).isTrue();
}
项目:hibernate4-memcached    文件:MemcachedRegionAccessStrategyTest.java   
@Test
public void isMinimalPutsEnabled_false() throws Exception {
    Settings settings = new TestingSettingsBuilder().setField("minimalPutsEnabled", false).build();
    when(generalDataMemcachedRegion.getSettings()).thenReturn(settings);

    assertThat(memcachedRegionAccessStrategy.isMinimalPutsEnabled()).isFalse();
}
项目:hibernate4-memcached    文件:GeneralDataMemcachedRegionTest.java   
public RefineKeyOverridedGeneralDataMemcachedRegion(CacheNamespace cacheNamespace,
                                                    OverridableReadOnlyProperties properties,
                                                    CacheDataDescription metadata, Settings settings,
                                                    MemcachedAdapter memcachedAdapter,
                                                    HibernateCacheTimestamper hibernateCacheTimestamper) {
    super(cacheNamespace, properties, metadata, settings, memcachedAdapter, hibernateCacheTimestamper);
}
项目:lightblue-rdbms    文件:RDBMSJDBCBinder.java   
public RDBMSJDBCBinder(RDBMSConfiguration rdbmsConfiguration, Settings settings, Mappings mappings, ReverseEngineeringStrategy revEngStrategy) {
    super(rdbmsConfiguration,settings,mappings,revEngStrategy);
    this.cfg = rdbmsConfiguration;
    this.settings = settings;
    this.mappings = mappings;
    this.revEngStrategy = revEngStrategy;
}
项目:esup-dematec    文件:IndexController.java   
private String getHbm2ddlAuto() {
    Session session = entityManager.unwrap(Session.class);
    SessionFactoryImpl sessionImpl = (SessionFactoryImpl)session.getSessionFactory();
    Settings setting = sessionImpl.getSettings();
    String hbm2ddlAuto = setting.isAutoCreateSchema() ? "create" : "update";
    return hbm2ddlAuto;
}
项目:health-and-care-developer-network    文件:AbstractHazelcastCacheRegionFactory.java   
public void start(final Settings settings, final Properties properties) throws CacheException {
    LOG.log(Level.INFO, "Starting up HazelcastCacheRegionFactory...");
    if (instance == null || !instance.getLifecycleService().isRunning()) {
        instanceLoader = HazelcastInstanceFactory.createInstanceLoader(properties);
        instance = instanceLoader.loadInstance();
    }
}
项目:lemon    文件:SessionFactoryWrapper.java   
public Settings getSettings() {
    return sessionFactoryImplementor.getSettings();
}
项目:lams    文件:LocalRegionFactoryProxy.java   
@Override
public void start(Settings settings, Properties properties) throws CacheException {
    this.regionFactory.start(settings, properties);
}