1 package org.hibernate.cache; 3 4 import net.sf.swarmcache.CacheConfiguration; 5 import net.sf.swarmcache.CacheConfigurationManager; 6 import net.sf.swarmcache.CacheFactory; 7 import net.sf.swarmcache.ObjectCache; 8 9 import java.util.Properties ; 10 11 16 public class SwarmCacheProvider implements CacheProvider { 17 18 private CacheFactory factory; 19 20 public Cache buildCache(String regionName, Properties properties) throws CacheException { 21 ObjectCache cache = factory.createCache(regionName); 22 if (cache==null) { 23 throw new CacheException("SwarmCache did not create a cache: " + regionName); 24 } 25 return new SwarmCache(cache, regionName); 26 } 27 28 public long nextTimestamp() { 29 return System.currentTimeMillis() / 100; 30 } 31 32 38 public void start(Properties properties) throws CacheException { 39 CacheConfiguration config = CacheConfigurationManager.getConfig(properties); 40 factory = new CacheFactory(config); 41 } 42 43 47 public void stop() { 48 if (factory != null) { 49 factory.shutdown(); 50 factory = null; 51 } 52 } 53 54 public boolean isMinimalPutsEnabledByDefault() { 55 return true; 56 } 57 58 } 59 | Popular Tags |