ehcache

net.sf.ehcache.hibernate
Class EhCacheProvider

java.lang.Object
  extended by net.sf.ehcache.hibernate.EhCacheProvider

Deprecated.

@Deprecated
public final class EhCacheProvider
extends Object

Cache Provider plugin for Hibernate 3.2 and ehcache-1.2. New in this provider are ehcache support for multiple Hibernate session factories, each with its own ehcache configuration, and non Serializable keys and values. 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.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 net.sf.ehcache.configurationResourceName An example to set an ehcach configuration called ehcache-2.xml would be net.sf.ehcache.configurationResourceName=/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.org for documentation on ehcache

Version:
$Id: EhCacheProvider.java 5594 2012-05-07 16:04:31Z cdennis $
Author:
Greg Luck, Emmanuel Bernard

Field Summary
protected  CacheManager manager
          CacheManager instance that creates/builds Cache instances for this provider.
static String NET_SF_EHCACHE_CONFIGURATION_RESOURCE_NAME
          Deprecated. The Hibernate system property specifying the location of the ehcache configuration file name.
 
Constructor Summary
EhCacheProvider()
          Deprecated.  
 
Method Summary
 Cache buildCache(String name, Properties properties)
          Builds a Cache.
 boolean isMinimalPutsEnabledByDefault()
          Whether to optimize for minimals puts or minimal gets.
protected  URL loadResource(String configurationResourceName)
          Load the supplied resource from the classpath.
 long nextTimestamp()
          Returns the next timestamp.
 void start(Properties properties)
          Deprecated. Callback to perform any necessary initialization of the underlying cache implementation during SessionFactory construction.
 void stop()
          Deprecated. Callback to perform any necessary cleanup of the underlying cache implementation during SessionFactory.close().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NET_SF_EHCACHE_CONFIGURATION_RESOURCE_NAME

public static final 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.

Constructor Detail

EhCacheProvider

public EhCacheProvider()
Deprecated. 
Method Detail

start

public final void start(Properties properties)
                 throws CacheException
Deprecated. 
Callback to perform any necessary initialization of the underlying cache implementation during SessionFactory construction.

Parameters:
properties - current configuration settings.
Throws:
CacheException

stop

public final void stop()
Deprecated. 
Callback to perform any necessary cleanup of the underlying cache implementation during SessionFactory.close().


buildCache

public final Cache buildCache(String name,
                              Properties properties)
                       throws CacheException
Builds 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.

Parameters:
name - the name of the cache. Must match a cache configured in ehcache.xml
properties - 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
CacheException

nextTimestamp

public final long nextTimestamp()
Returns the next timestamp.


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.

Returns:
true, optimize for minimal puts

loadResource

protected URL loadResource(String configurationResourceName)
Load the supplied resource from the classpath.


ehcache

Copyright 2001-2017, Terracotta, Inc.