Class EhCacheRegionFactory
- java.lang.Object
-
- net.sf.ehcache.hibernate.EhCacheRegionFactory
-
- All Implemented Interfaces:
org.hibernate.cache.RegionFactory
public class EhCacheRegionFactory extends java.lang.ObjectA non-singleton EhCacheRegionFactory implementation.- Author:
- Chris Dennis, Greg Luck, Emmanuel Bernard, Abhishek Sanoujam
-
-
Field Summary
Fields Modifier and Type Field Description protected EhcacheAccessStrategyFactoryaccessStrategyFactoryEhcacheAccessStrategyFactoryfor creating various access strategiesprotected CacheManagermanagerEhcache CacheManager that supplied Ehcache instances for this Hibernate RegionFactory.protected ProviderMBeanRegistrationHelpermbeanRegistrationHelperMBean registration helper class instance for Ehcache Hibernate MBeans.static java.lang.StringNET_SF_EHCACHE_CACHE_MANAGER_NAMEThe Hibernate system property specifying the name of the CacheManager being created.static java.lang.StringNET_SF_EHCACHE_CONFIGURATION_RESOURCE_NAMEThe Hibernate system property specifying the location of the ehcache configuration file name.protected org.hibernate.cfg.SettingssettingsSettings object for the Hibernate persistence unit.
-
Constructor Summary
Constructors Constructor Description EhCacheRegionFactory(java.util.Properties prop)Creates a non-singleton EhCacheRegionFactory
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.hibernate.cache.CollectionRegionbuildCollectionRegion(java.lang.String regionName, java.util.Properties properties, org.hibernate.cache.CacheDataDescription metadata)org.hibernate.cache.EntityRegionbuildEntityRegion(java.lang.String regionName, java.util.Properties properties, org.hibernate.cache.CacheDataDescription metadata)org.hibernate.cache.QueryResultsRegionbuildQueryResultsRegion(java.lang.String regionName, java.util.Properties properties)org.hibernate.cache.TimestampsRegionbuildTimestampsRegion(java.lang.String regionName, java.util.Properties properties)org.hibernate.cache.access.AccessTypegetDefaultAccessType()Default access-type used when the configured using JPA 2.0 config.booleanisMinimalPutsEnabledByDefault()Whether to optimize for minimals puts or minimal gets.protected static java.net.URLloadResource(java.lang.String configurationResourceName)Load a resource from the classpath.longnextTimestamp()voidstart(org.hibernate.cfg.Settings settings, java.util.Properties properties)voidstop()
-
-
-
Field Detail
-
NET_SF_EHCACHE_CONFIGURATION_RESOURCE_NAME
public static final java.lang.String NET_SF_EHCACHE_CONFIGURATION_RESOURCE_NAME
The Hibernate system property specifying the location of the ehcache configuration file name.If not set, ehcache.xml will be looked for in the root of the classpath.
If set to say ehcache-1.xml, ehcache-1.xml will be looked for in the root of the classpath.
- See Also:
- Constant Field Values
-
NET_SF_EHCACHE_CACHE_MANAGER_NAME
public static final java.lang.String NET_SF_EHCACHE_CACHE_MANAGER_NAME
The Hibernate system property specifying the name of the CacheManager being created.If not set, it will either use the ehcache.xml to name the CacheManager, or fallback to default CacheManager naming.
- See Also:
- Constant Field Values
-
mbeanRegistrationHelper
protected final ProviderMBeanRegistrationHelper mbeanRegistrationHelper
MBean registration helper class instance for Ehcache Hibernate MBeans.
-
manager
protected volatile CacheManager manager
Ehcache CacheManager that supplied Ehcache instances for this Hibernate RegionFactory.
-
settings
protected org.hibernate.cfg.Settings settings
Settings object for the Hibernate persistence unit.
-
accessStrategyFactory
protected final EhcacheAccessStrategyFactory accessStrategyFactory
EhcacheAccessStrategyFactoryfor creating various access strategies
-
-
Method Detail
-
start
public void start(org.hibernate.cfg.Settings settings, java.util.Properties properties) throws org.hibernate.cache.CacheException- Throws:
org.hibernate.cache.CacheException
-
stop
public void stop()
-
isMinimalPutsEnabledByDefault
public boolean isMinimalPutsEnabledByDefault()
Whether to optimize for minimals puts or minimal gets.Indicates whether when operating in non-strict read/write or read-only mode Hibernate should optimize the access patterns for minimal puts or minimal gets. In Ehcache we default to minimal puts since this should have minimal to no affect on unclustered users, and has great benefit for clustered users.
This setting can be overridden by setting the "hibernate.cache.use_minimal_puts" property in the Hibernate configuration.
- Specified by:
isMinimalPutsEnabledByDefaultin interfaceorg.hibernate.cache.RegionFactory- Returns:
- true, optimize for minimal puts
-
nextTimestamp
public long nextTimestamp()
- Specified by:
nextTimestampin interfaceorg.hibernate.cache.RegionFactory
-
buildEntityRegion
public org.hibernate.cache.EntityRegion buildEntityRegion(java.lang.String regionName, java.util.Properties properties, org.hibernate.cache.CacheDataDescription metadata) throws org.hibernate.cache.CacheException- Specified by:
buildEntityRegionin interfaceorg.hibernate.cache.RegionFactory- Throws:
org.hibernate.cache.CacheException
-
buildCollectionRegion
public org.hibernate.cache.CollectionRegion buildCollectionRegion(java.lang.String regionName, java.util.Properties properties, org.hibernate.cache.CacheDataDescription metadata) throws org.hibernate.cache.CacheException- Specified by:
buildCollectionRegionin interfaceorg.hibernate.cache.RegionFactory- Throws:
org.hibernate.cache.CacheException
-
buildQueryResultsRegion
public org.hibernate.cache.QueryResultsRegion buildQueryResultsRegion(java.lang.String regionName, java.util.Properties properties) throws org.hibernate.cache.CacheException- Specified by:
buildQueryResultsRegionin interfaceorg.hibernate.cache.RegionFactory- Throws:
org.hibernate.cache.CacheException
-
buildTimestampsRegion
public org.hibernate.cache.TimestampsRegion buildTimestampsRegion(java.lang.String regionName, java.util.Properties properties) throws org.hibernate.cache.CacheException- Specified by:
buildTimestampsRegionin interfaceorg.hibernate.cache.RegionFactory- Throws:
org.hibernate.cache.CacheException
-
loadResource
protected static java.net.URL loadResource(java.lang.String configurationResourceName)
Load a resource from the classpath.
-
getDefaultAccessType
public org.hibernate.cache.access.AccessType getDefaultAccessType()
Default access-type used when the configured using JPA 2.0 config. JPA 2.0 allows@Cacheable(true)to be attached to an entity without any access type or usage qualification.We are conservative here in specifying
AccessType.READ_WRITEso as to follow the mantra of "do no harm".This is a Hibernate 3.5 method.
- Specified by:
getDefaultAccessTypein interfaceorg.hibernate.cache.RegionFactory
-
-