Class EhCacheRegionFactory

  • All Implemented Interfaces:
    Serializable, org.hibernate.cache.spi.RegionFactory, org.hibernate.service.Service, org.hibernate.service.spi.Stoppable

    public class EhCacheRegionFactory
    extends org.hibernate.cache.ehcache.internal.EhcacheRegionFactory
    A Hibernate EhCacheRegionFactory implementation that supports directly setting the CacheManager from an existing instance. This allows us to dynamically configure out CacheManager using Spring and then pass it into Hibernate. Unfortunately, the EhCacheRegionFactory cannot be passed as an instance object to Hibernate, but instead as a class name to be created by Hibernate itself. Thus, there is no easy way to connect it the Spring application context. As a kludge to get around that, we have a static setStaticCacheManagerInstance(CacheManager) that can be called from the Spring application context config to supply the CacheManager instance. It's a hack, but I don't see any way around it.
    Author:
    bdferris
    See Also:
    Serialized Form
    • Field Summary

      • Fields inherited from class org.hibernate.cache.spi.AbstractRegionFactory

        LEGACY_QUERY_RESULTS_REGION_UNQUALIFIED_NAMES, LEGACY_UPDATE_TIMESTAMPS_REGION_UNQUALIFIED_NAMES
      • Fields inherited from interface org.hibernate.cache.spi.RegionFactory

        DEFAULT_QUERY_RESULTS_REGION_UNQUALIFIED_NAME, DEFAULT_UPDATE_TIMESTAMPS_REGION_UNQUALIFIED_NAME
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void releaseFromUse()  
      protected net.sf.ehcache.CacheManager resolveCacheManager​(org.hibernate.boot.spi.SessionFactoryOptions settings, Map properties)  
      void setCacheManager​(net.sf.ehcache.CacheManager cacheManager)  
      static void setStaticCacheManagerInstance​(net.sf.ehcache.CacheManager cacheManager)  
      • Methods inherited from class org.hibernate.cache.ehcache.internal.EhcacheRegionFactory

        buildDomainDataRegion, cacheExists, createCache, createDomainDataStorageAccess, createQueryResultsRegionStorageAccess, createTimestampsRegionStorageAccess, defaultRegionName, getCacheManager, getImplicitCacheKeysFactory, getOrCreateCache, getTimeout, isStarted, loadResource, prepareForUse, useNormalCacheManager
      • Methods inherited from class org.hibernate.cache.spi.support.RegionFactoryTemplate

        buildQueryResultsRegion, buildTimestampsRegion
      • Methods inherited from class org.hibernate.cache.spi.AbstractRegionFactory

        createTransactionContext, getDefaultAccessType, getOptions, isMinimalPutsEnabledByDefault, nextTimestamp, qualify, start, stop, verifiedStartStatus, verifyStarted
    • Constructor Detail

      • EhCacheRegionFactory

        public EhCacheRegionFactory()
    • Method Detail

      • setStaticCacheManagerInstance

        public static void setStaticCacheManagerInstance​(net.sf.ehcache.CacheManager cacheManager)
      • releaseFromUse

        protected void releaseFromUse()
        Overrides:
        releaseFromUse in class org.hibernate.cache.ehcache.internal.EhcacheRegionFactory
      • setCacheManager

        public void setCacheManager​(net.sf.ehcache.CacheManager cacheManager)
      • resolveCacheManager

        protected net.sf.ehcache.CacheManager resolveCacheManager​(org.hibernate.boot.spi.SessionFactoryOptions settings,
                                                                  Map properties)
        Overrides:
        resolveCacheManager in class org.hibernate.cache.ehcache.internal.EhcacheRegionFactory