01: package org.shiftone.cache.adaptor;
02:
03: import net.sf.hibernate.cache.CacheException;
04: import net.sf.hibernate.cache.Timestamper;
05:
06: /**
07: * Makes a shiftone cache look like a hibernate cache.
08: *
09: * @version $Revision: 1.2 $
10: * @author <a href="mailto:jeff@shiftone.org">Jeff Drost</a>
11: */
12: public class HibernateCache implements net.sf.hibernate.cache.Cache {
13:
14: private final org.shiftone.cache.Cache cache;
15:
16: public HibernateCache(org.shiftone.cache.Cache cache) {
17: this .cache = cache;
18: }
19:
20: public final Object get(Object key) throws CacheException {
21: return cache.getObject(key);
22: }
23:
24: public final void put(Object key, Object value)
25: throws CacheException {
26: cache.addObject(key, value);
27: }
28:
29: public final void remove(Object key) throws CacheException {
30: cache.remove(key);
31: }
32:
33: public final void clear() throws CacheException {
34: cache.clear();
35: }
36:
37: public final void destroy() throws CacheException {
38: cache.clear();
39: }
40:
41: /**
42: * NOOP
43: */
44: public final void lock(Object o) throws CacheException {
45: }
46:
47: /**
48: * NOOP
49: */
50: public final void unlock(Object o) throws CacheException {
51: }
52:
53: public final long nextTimestamp() {
54: return Timestamper.next();
55: }
56:
57: public final int getTimeout() {
58: return 1;
59: }
60: }
|