com.opensymphony.oscache.hibernate
Class OSCacheProvider

java.lang.Object
  extended by com.opensymphony.oscache.hibernate.OSCacheProvider
All Implemented Interfaces:
org.hibernate.cache.CacheProvider

public class OSCacheProvider
extends Object
implements org.hibernate.cache.CacheProvider

Cache provider plugin for Hibernate 3.2 and OpenSymphony OSCache 2.4.

This implementation assumes that identifiers have well-behaved toString() methods.

To enable OSCache for Hibernate's second level cache add the following line to Hibernate's configuration e.g. hibernate.cfg.xml): hibernate.cache.provider_class=com.opensymphony.oscache.hibernate.OSCacheProvider To configure a different configuration file use the following parameter in the Hibernate's configuration: com.opensymphony.oscache.configurationResourceName=[path to oscache-hibernate.properties]

Version:
$Revision:$

Field Summary
static String OSCACHE_CONFIGURATION_RESOURCE_NAME
          In the Hibernate system property you can specify the location of the oscache configuration file name.
static String OSCACHE_CRON
          The OSCache CRON expression property suffix.
static String OSCACHE_REFRESH_PERIOD
          The OSCache refresh period property suffix.
 
Constructor Summary
OSCacheProvider()
           
 
Method Summary
 org.hibernate.cache.Cache buildCache(String region, Properties properties)
          Builds a new Cache instance, and gets it's properties from the GeneralCacheAdministrator GeneralCacheAdministrator which reads the properties file (oscache.properties) in the start method:
 boolean isMinimalPutsEnabledByDefault()
          This method isn't documented in Hibernate:
 long nextTimestamp()
           
 void start(Properties hibernateSystemProperties)
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OSCACHE_CONFIGURATION_RESOURCE_NAME

public static final String OSCACHE_CONFIGURATION_RESOURCE_NAME
In the Hibernate system property you can specify the location of the oscache configuration file name.

See Also:
Constant Field Values

OSCACHE_REFRESH_PERIOD

public static final String OSCACHE_REFRESH_PERIOD
The OSCache refresh period property suffix.

See Also:
Constant Field Values

OSCACHE_CRON

public static final String OSCACHE_CRON
The OSCache CRON expression property suffix.

See Also:
Constant Field Values
Constructor Detail

OSCacheProvider

public OSCacheProvider()
Method Detail

buildCache

public org.hibernate.cache.Cache buildCache(String region,
                                            Properties properties)
                                     throws org.hibernate.cache.CacheException
Builds a new Cache instance, and gets it's properties from the GeneralCacheAdministrator GeneralCacheAdministrator which reads the properties file (oscache.properties) in the start method:

Specified by:
buildCache in interface org.hibernate.cache.CacheProvider
Parameters:
region - the region of the cache
properties - not used
Returns:
the hibernate 2nd level cache
Throws:
org.hibernate.cache.CacheException
See Also:
start(java.util.Properties), CacheProvider.buildCache(java.lang.String, java.util.Properties)

nextTimestamp

public long nextTimestamp()
Specified by:
nextTimestamp in interface org.hibernate.cache.CacheProvider
See Also:
CacheProvider.nextTimestamp()

isMinimalPutsEnabledByDefault

public boolean isMinimalPutsEnabledByDefault()
This method isn't documented in Hibernate:

Specified by:
isMinimalPutsEnabledByDefault in interface org.hibernate.cache.CacheProvider
See Also:
CacheProvider.isMinimalPutsEnabledByDefault()

stop

public void stop()
Specified by:
stop in interface org.hibernate.cache.CacheProvider
See Also:
CacheProvider.stop()

start

public void start(Properties hibernateSystemProperties)
           throws org.hibernate.cache.CacheException
Specified by:
start in interface org.hibernate.cache.CacheProvider
Throws:
org.hibernate.cache.CacheException
See Also:
CacheProvider.start(java.util.Properties)

OSCache Project Page