@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; }
private static CacheConcurrencyStrategy determineCacheConcurrencyStrategy(Mappings mappings) { if ( DEFAULT_CACHE_CONCURRENCY_STRATEGY == null ) { final RegionFactory cacheRegionFactory = SettingsFactory.createRegionFactory( mappings.getConfigurationProperties(), true ); DEFAULT_CACHE_CONCURRENCY_STRATEGY = CacheConcurrencyStrategy.fromAccessType( cacheRegionFactory.getDefaultAccessType() ); } return DEFAULT_CACHE_CONCURRENCY_STRATEGY; }
/** * Tries to extract <code>HazelcastInstance</code> from <code>SessionFactoryImplementor</code>. * * @param sessionFactory the {@code SessionFactoryImplementor} to retrieve the Hazelcast instance for * @return currently used <code>HazelcastInstance</code> or null if an error occurs. */ public static HazelcastInstance getHazelcastInstance(final SessionFactoryImplementor sessionFactory) { final RegionFactory rf = sessionFactory.getSessionFactoryOptions() .getServiceRegistry().getService(RegionFactory.class); if (rf instanceof AbstractHazelcastCacheRegionFactory) { return ((AbstractHazelcastCacheRegionFactory) rf).getHazelcastInstance(); } else { LOGGER.warning("Current 2nd level cache implementation is not HazelcastCacheRegionFactory!"); } return null; }
/** * 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; }
@Override @SuppressWarnings({ CompilerWarnings.RAWTYPES }) public CacheRegionFactory initiateService(Map configValues, ServiceRegistryImplementor serviceRegistry) { CacheRegionFactory service = super.initiateService(configValues, serviceRegistry); serviceRegistry.locateServiceBinding(RegionFactory.class).setService(service); return service; }
public RegionFactory getRegionFactory() { return regionFactory; }
void setRegionFactory(RegionFactory regionFactory) { this.regionFactory = regionFactory; }
@Override public AccessType initialize() { final RegionFactory regionFactory = getServiceRegistry().getService( RegionFactory.class ); return regionFactory.getDefaultAccessType(); }
@Override public RegionFactory getRegionFactory() { return regionFactory; }
@Override public Class<RegionFactory> getServiceInitiated() { return RegionFactory.class; }
@Override public Class<? extends RegionFactory> getEhCacheRegionFactory() { return ehCacheRegionFactory; }
/** * Set the Hibernate RegionFactory to use for the SessionFactory. * Allows for using a Spring-managed RegionFactory instance. * <p>Note: If this is set, the Hibernate settings should not define a * cache provider to avoid meaningless double configuration. * @see org.hibernate.cache.spi.RegionFactory * @see LocalSessionFactoryBuilder#setCacheRegionFactory */ public void setCacheRegionFactory(RegionFactory cacheRegionFactory) { this.cacheRegionFactory = cacheRegionFactory; }
/** * Set the Hibernate RegionFactory to use for the SessionFactory. * Allows for using a Spring-managed RegionFactory instance. * <p>Note: If this is set, the Hibernate settings should not define a * cache provider to avoid meaningless double configuration. * @see org.hibernate.cache.spi.RegionFactory */ public LocalSessionFactoryBuilder setCacheRegionFactory(RegionFactory cacheRegionFactory) { this.cacheRegionFactory = cacheRegionFactory; return this; }
/** * * @return The {@code RegionFactory} */ public RegionFactory getRegionFactory();
/** * Set the Hibernate RegionFactory to use for the SessionFactory. * Allows for using a Spring-managed RegionFactory instance. * <p>Note: If this is set, the Hibernate settings should not define a * cache provider to avoid meaningless double configuration. * @since 4.0 * @see org.hibernate.cache.spi.RegionFactory * @see LocalSessionFactoryBuilder#setCacheRegionFactory */ public void setCacheRegionFactory(RegionFactory cacheRegionFactory) { this.cacheRegionFactory = cacheRegionFactory; }
/** * Set the Hibernate RegionFactory to use for the SessionFactory. * Allows for using a Spring-managed RegionFactory instance. * <p>Note: If this is set, the Hibernate settings should not define a * cache provider to avoid meaningless double configuration. * @since 4.0 * @see org.hibernate.cache.spi.RegionFactory */ public LocalSessionFactoryBuilder setCacheRegionFactory(RegionFactory cacheRegionFactory) { this.cacheRegionFactory = cacheRegionFactory; return this; }
Class<? extends RegionFactory> getEhCacheRegionFactory();