net.sf.ehcache.hibernate
Class Plugin

java.lang.Object
  extended bynet.sf.ehcache.hibernate.Plugin
All Implemented Interfaces:
net.sf.hibernate.cache.Cache

public class Plugin
extends java.lang.Object
implements net.sf.hibernate.cache.Cache

EHCache plugin for Hibernate EHCache uses a MemoryStore and a DiskStore. The DiskStore requires that both keys and values be Serializable. For this reason this plugin throws Exceptions when either of these are not castable to Serializable.

Version:
$Id: Plugin.java,v 1.11 2003/11/18 01:37:04 gregluck Exp $
Author:
Greg Luck

Constructor Summary
Plugin(java.lang.String name)
          Creates a new Hibernate pluggable cache based on a cache name.
 
Method Summary
 void clear()
          Remove all elements in the cache, but leave the cache in a useable state.
 void destroy()
          Remove the cache and make it unuseable.
 java.lang.Object get(java.lang.Object key)
          Gets a value of an element which matches the given key.
 int getTimeout()
          Returns the lock timeout for this cache.
 void lock(java.lang.Object key)
          Calls to this method should perform there own synchronization.
 long nextTimestamp()
          Gets the next timestamp;
 void put(java.lang.Object key, java.lang.Object value)
          Puts an object into the cache.
 void remove(java.lang.Object key)
          Removes the element which matches the key.
 void unlock(java.lang.Object key)
          Calls to this method should perform there own synchronization.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Plugin

public Plugin(java.lang.String name)
       throws net.sf.hibernate.cache.CacheException
Creates a new Hibernate pluggable cache based on a cache name.

Parameters:
name - the name of the cache. This cache must have already been configured.
Throws:
net.sf.hibernate.cache.CacheException - If there is no cache with the given name.
Method Detail

get

public java.lang.Object get(java.lang.Object key)
                     throws net.sf.hibernate.cache.CacheException
Gets a value of an element which matches the given key.

Specified by:
get in interface net.sf.hibernate.cache.Cache
Parameters:
key - the key of the element to return.
Returns:
The value placed into the cache with an earlier put, or null if not found or expired
Throws:
net.sf.hibernate.cache.CacheException

put

public void put(java.lang.Object key,
                java.lang.Object value)
         throws net.sf.hibernate.cache.CacheException
Puts an object into the cache.

Specified by:
put in interface net.sf.hibernate.cache.Cache
Parameters:
key - a Serializable key
value - a Serializable value
Throws:
net.sf.hibernate.cache.CacheException - if the parameters are not Serializable, the CacheManager is shutdown or another Exception occurs.

remove

public void remove(java.lang.Object key)
            throws net.sf.hibernate.cache.CacheException
Removes the element which matches the key.

If no element matches, nothing is removed and no Exception is thrown.

Specified by:
remove in interface net.sf.hibernate.cache.Cache
Parameters:
key - the key of the element to remove
Throws:
net.sf.hibernate.cache.CacheException

clear

public void clear()
           throws net.sf.hibernate.cache.CacheException
Remove all elements in the cache, but leave the cache in a useable state.

Specified by:
clear in interface net.sf.hibernate.cache.Cache
Throws:
net.sf.hibernate.cache.CacheException

destroy

public void destroy()
             throws net.sf.hibernate.cache.CacheException
Remove the cache and make it unuseable.

Specified by:
destroy in interface net.sf.hibernate.cache.Cache
Throws:
net.sf.hibernate.cache.CacheException

lock

public void lock(java.lang.Object key)
          throws net.sf.hibernate.cache.CacheException
Calls to this method should perform there own synchronization. It is provided for distributed caches. Because EHCache is not distributed this method does nothing.

Specified by:
lock in interface net.sf.hibernate.cache.Cache
Throws:
net.sf.hibernate.cache.CacheException

unlock

public void unlock(java.lang.Object key)
            throws net.sf.hibernate.cache.CacheException
Calls to this method should perform there own synchronization. It is provided for distributed caches. Because EHCache is not distributed this method does nothing.

Specified by:
unlock in interface net.sf.hibernate.cache.Cache
Throws:
net.sf.hibernate.cache.CacheException

nextTimestamp

public long nextTimestamp()
Gets the next timestamp;

Specified by:
nextTimestamp in interface net.sf.hibernate.cache.Cache

getTimeout

public int getTimeout()
Returns the lock timeout for this cache.

Specified by:
getTimeout in interface net.sf.hibernate.cache.Cache