1 package org.hibernate.cache; 3 4 import java.util.Properties ; 5 6 import org.hibernate.util.PropertiesHelper; 7 import org.hibernate.util.StringHelper; 8 9 import com.opensymphony.oscache.base.CacheEntry; 10 import com.opensymphony.oscache.base.Config; 11 12 18 public class OSCacheProvider implements CacheProvider { 19 20 23 public static final String OSCACHE_REFRESH_PERIOD = "refresh.period"; 24 27 public static final String OSCACHE_CRON = "cron"; 28 31 public static final String OSCACHE_CAPACITY = "capacity"; 32 33 private static final Properties OSCACHE_PROPERTIES = new Config().getProperties(); 34 35 45 public Cache buildCache(String region, Properties properties) throws CacheException { 46 47 int refreshPeriod = PropertiesHelper.getInt( 48 StringHelper.qualify(region, OSCACHE_REFRESH_PERIOD), 49 OSCACHE_PROPERTIES, 50 CacheEntry.INDEFINITE_EXPIRY 51 ); 52 String cron = OSCACHE_PROPERTIES.getProperty( StringHelper.qualify(region, OSCACHE_CRON) ); 53 54 final OSCache cache = new OSCache(refreshPeriod, cron, region); 56 57 Integer capacity = PropertiesHelper.getInteger( StringHelper.qualify(region, OSCACHE_CAPACITY), OSCACHE_PROPERTIES ); 58 if ( capacity!=null ) cache.setCacheCapacity( capacity.intValue() ); 59 60 return cache; 61 } 62 63 public long nextTimestamp() { 64 return Timestamper.next(); 65 } 66 67 73 public void start(Properties properties) throws CacheException { 74 } 75 76 80 public void stop() { 81 } 82 83 public boolean isMinimalPutsEnabledByDefault() { 84 return false; 85 } 86 87 } 88 | Popular Tags |