Class SingletonEhCacheProvider
- java.lang.Object
-
- net.sf.ehcache.hibernate.SingletonEhCacheProvider
-
- All Implemented Interfaces:
org.hibernate.cache.CacheProvider
@Deprecated public final class SingletonEhCacheProvider extends java.lang.ObjectDeprecated.Singleton cache Provider plugin for Hibernate 3.2 and ehcache-1.2. New in this provider is support for non Serializable keys and values. This provider works as a Singleton. No matter how many Hibernate Configurations you have, only one ehcache CacheManager is used. See EhCacheProvider for a non-singleton implementation.Ehcache-1.2 also has many other features such as cluster support and listeners, which can be used seamlessly simply by configurion in ehcache.xml.
Use
hibernate.cache.provider_class=net.sf.ehcache.hibernate.SingletonEhCacheProviderin the Hibernate configuration to enable this provider for Hibernate's second level cache.Updated for ehcache-1.2. Note this provider requires ehcache-1.2.jar. Make sure ehcache-1.1.jar or earlier is not in the classpath or it will not work.
See http://ehcache.org for documentation on ehcache
- Version:
- $Id$
- Author:
- Greg Luck, Emmanuel Bernard
-
-
Field Summary
Fields Modifier and Type Field Description protected CacheManagermanagerCacheManager instance that creates/builds Cache instances for this provider.static java.lang.StringNET_SF_EHCACHE_CONFIGURATION_RESOURCE_NAMEDeprecated.The Hibernate system property specifying the location of the ehcache configuration file name.
-
Constructor Summary
Constructors Constructor Description SingletonEhCacheProvider()Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description org.hibernate.cache.CachebuildCache(java.lang.String name, java.util.Properties properties)Builds a Cache.booleanisMinimalPutsEnabledByDefault()Whether to optimize for minimals puts or minimal gets.protected java.net.URLloadResource(java.lang.String configurationResourceName)Load the supplied resource from the classpath.longnextTimestamp()Returns the next timestamp.voidstart(java.util.Properties properties)Deprecated.Callback to perform any necessary initialization of the underlying cache implementation during SessionFactory construction.voidstop()Deprecated.Callback to perform any necessary cleanup of the underlying cache implementation during SessionFactory.close().
-
-
-
Field Detail
-
NET_SF_EHCACHE_CONFIGURATION_RESOURCE_NAME
public static final java.lang.String NET_SF_EHCACHE_CONFIGURATION_RESOURCE_NAME
Deprecated.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
-
manager
protected volatile CacheManager manager
CacheManager instance that creates/builds Cache instances for this provider.
-
-
Method Detail
-
start
public final void start(java.util.Properties properties) throws org.hibernate.cache.CacheExceptionDeprecated.Callback to perform any necessary initialization of the underlying cache implementation during SessionFactory construction.- Parameters:
properties- current configuration settings.- Throws:
org.hibernate.cache.CacheException
-
stop
public void stop()
Deprecated.Callback to perform any necessary cleanup of the underlying cache implementation during SessionFactory.close().
-
buildCache
public final org.hibernate.cache.Cache buildCache(java.lang.String name, java.util.Properties properties) throws org.hibernate.cache.CacheExceptionBuilds a Cache.Even though this method provides properties, they are not used. Properties for EHCache are specified in the ehcache.xml file. Configuration will be read from ehcache.xml for a cache declaration where the name attribute matches the name parameter in this builder.
- Specified by:
buildCachein interfaceorg.hibernate.cache.CacheProvider- Parameters:
name- the name of the cache. Must match a cache configured in ehcache.xmlproperties- not used- Returns:
- a newly built cache will be built and initialised
- Throws:
org.hibernate.cache.CacheException- inter alia, if a cache of the same name already exists
-
nextTimestamp
public final long nextTimestamp()
Returns the next timestamp.- Specified by:
nextTimestampin interfaceorg.hibernate.cache.CacheProvider
-
isMinimalPutsEnabledByDefault
public final 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.CacheProvider- Returns:
- true, optimize for minimal puts
-
loadResource
protected java.net.URL loadResource(java.lang.String configurationResourceName)
Load the supplied resource from the classpath.
-
-