public class EhCacheProvider extends Object implements CacheProvider
hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
in the Hibernate configuration
to enable this provider for Hibernate's second level cache.
When configuring multiple ehcache CacheManagers, as you would where you have multiple Hibernate Configurations and
multiple SessionFactories, specify in each Hibernate configuration the ehcache configuration using
the property hibernate.cache.provider_configuration_file_resource_path
An example to set an ehcache configuration
called ehcache-2.xml would be hibernate.cache.provider_configuration_file_resource_path=/ehcache-2.xml
. If the leading
slash is not there one will be added. The configuration file will be looked for in the root of the classpath.
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.sf.net for documentation on ehcache
Constructor and Description |
---|
EhCacheProvider() |
Modifier and Type | Method and Description |
---|---|
Cache |
buildCache(String name,
Properties properties)
Builds a Cache.
|
boolean |
isMinimalPutsEnabledByDefault() |
long |
nextTimestamp()
Returns the next timestamp.
|
void |
start(Properties properties)
Callback to perform any necessary initialization of the underlying cache implementation
during SessionFactory construction.
|
void |
stop()
Callback to perform any necessary cleanup of the underlying cache implementation
during SessionFactory.close().
|
public Cache buildCache(String name, Properties properties) throws CacheException
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.
buildCache
in interface CacheProvider
name
- the name of the cache. Must match a cache configured in ehcache.xmlproperties
- not usedCacheException
- inter alia, if a cache of the same name already existspublic long nextTimestamp()
nextTimestamp
in interface CacheProvider
public void start(Properties properties) throws CacheException
start
in interface CacheProvider
properties
- current configuration settings.CacheException
public void stop()
stop
in interface CacheProvider
public boolean isMinimalPutsEnabledByDefault()
isMinimalPutsEnabledByDefault
in interface CacheProvider
Copyright © 2002-2015 Red Hat Middleware, LLC. All Rights Reserved