KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > database > impl > ExoCachePlugin


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.services.database.impl;
6
7 import java.io.Serializable JavaDoc;
8 import org.exoplatform.commons.utils.ExceptionUtil;
9 import org.exoplatform.services.cache.ExoCache;
10
11 import net.sf.hibernate.cache.CacheException;
12 import net.sf.hibernate.cache.Timestamper;
13
14 /**
15  * Jul 17, 2004
16  * @author: Tuan Nguyen
17  * @email: tuan08@users.sourceforge.net
18  * @version: $Id: ExoCachePlugin.java,v 1.1 2004/08/29 21:47:58 benjmestrallet Exp $
19  */

20 public class ExoCachePlugin implements net.sf.hibernate.cache.Cache {
21   private ExoCache cache_ ;
22   
23   public ExoCachePlugin(ExoCache cache) {
24     cache_ = cache ;
25   }
26
27   public Object JavaDoc get(Object JavaDoc key) throws CacheException {
28     //System.out.println("::::::::::::::::::::::::::::: get() key = " + key) ;
29
try {
30         return cache_.get((Serializable JavaDoc)key) ;
31     } catch (Exception JavaDoc ex) {
32         throw new CacheException(ex) ;
33     }
34   }
35   
36   public void put(Object JavaDoc key, Object JavaDoc value) throws CacheException {
37     //System.out.println("::::::::::::::::::::::::::::: put() key = " + key + " value " + value) ;
38
try {
39         cache_.put((Serializable JavaDoc)key, value) ;
40     } catch (Exception JavaDoc ex) {
41         throw new CacheException(ex) ;
42     }
43   }
44   
45   public void remove(Object JavaDoc key) throws CacheException {
46     //System.out.println("::::::::::::::::::::::::::::: remove() key = " + key) ;
47
try {
48         cache_.remove((Serializable JavaDoc)key) ;
49     } catch (Exception JavaDoc ex) {
50         throw new CacheException(ex) ;
51     }
52   }
53
54   public void clear() throws CacheException {
55     //System.out.println(ExpceptionUtil.getExoStackTrace(new Exception())) ;
56
try {
57       cache_.clear() ;
58     } catch (Exception JavaDoc ex) {
59       throw new CacheException(ex) ;
60     }
61   }
62
63   public void destroy() throws CacheException {
64     //System.out.println(ExpceptionUtil.getExoStackTrace(new Exception())) ;
65
}
66
67   public void lock(Object JavaDoc key) throws CacheException {
68   }
69
70
71   public void unlock(Object JavaDoc key) throws CacheException {
72   }
73
74   public long nextTimestamp() { return Timestamper.next(); }
75
76   /**
77    * Returns the lock timeout for this cache.
78    */

79   public int getTimeout() { return Timestamper.ONE_MS * 60000; }
80 }
Popular Tags