01: package org.shiftone.cache.adaptor;
02:
03: import net.sf.hibernate.cache.Cache;
04: import net.sf.hibernate.cache.CacheException;
05: import net.sf.hibernate.cache.CacheProvider;
06: import net.sf.hibernate.cache.Timestamper;
07: import org.shiftone.cache.CacheConfiguration;
08: import org.shiftone.cache.ConfigurationException;
09: import org.shiftone.cache.util.Log;
10:
11: import java.util.Properties;
12:
13: /**
14: * @version $Revision: 1.7 $
15: * @author <a href="mailto:jeff@shiftone.org">Jeff Drost</a>
16: */
17: public class HibernateCacheProvider implements CacheProvider {
18:
19: private static final Log LOG = new Log(HibernateCacheProvider.class);
20: private CacheConfiguration config;
21:
22: public HibernateCacheProvider() throws ConfigurationException {
23: config = new CacheConfiguration();
24: }
25:
26: public final Cache buildCache(String regionName,
27: Properties properties) throws CacheException {
28:
29: org.shiftone.cache.Cache cache = config
30: .createConfiguredCacheSafely(regionName);
31:
32: LOG.info("buildCache : " + cache);
33:
34: return new HibernateCache(cache);
35: }
36:
37: public final long nextTimestamp() {
38: return Timestamper.next();
39: }
40: }
|