From 846ea920b69a1437e99e20e3217bfeb64170711f Mon Sep 17 00:00:00 2001 From: Par Winzell Date: Thu, 1 Jul 2010 17:15:32 +0000 Subject: [PATCH] Make the adapter configurable, as was always the intention. --- .../com/samskivert/depot/EHCacheAdapter.java | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/java/com/samskivert/depot/EHCacheAdapter.java b/src/java/com/samskivert/depot/EHCacheAdapter.java index 193145b..7eefd1d 100644 --- a/src/java/com/samskivert/depot/EHCacheAdapter.java +++ b/src/java/com/samskivert/depot/EHCacheAdapter.java @@ -100,17 +100,34 @@ public class EHCacheAdapter new EHCacheConfig("depotResult", 5000, 300, 300); /** - * Creates an adapter using the supplied cache manager. Note: this adapter does not shut down - * the supplied manager when it is shutdown. The caller is responsible for shutting down the - * cache manager when it knows that Depot and any other clients no longer need it. + * Creates an adapter using the supplied cache manager with the default cache configurations. + * + * Note: this adapter does not shut down* the supplied manager when it is shutdown. The caller + * is responsible for shutting down the cache manager when it knows that Depot and any other + * clients no longer need it. */ public EHCacheAdapter (CacheManager cachemgr, String ident) + { + this(cachemgr, ident, EHCACHE_RECORD_CONFIG, EHCACHE_SHORT_KEYSET_CONFIG, + EHCACHE_LONG_KEYSET_CONFIG, EHCACHE_RESULT_CONFIG); + } + + /** + * Creates an adapter using the supplied cache manager with the specific cache configurations. + * + * Note: this adapter does not shut down* the supplied manager when it is shutdown. The caller + * is responsible for shutting down the cache manager when it knows that Depot and any other + * clients no longer need it. + */ + public EHCacheAdapter (CacheManager cachemgr, String ident, EHCacheConfig recordConfig, + EHCacheConfig shortKeySetConfig, EHCacheConfig longKeySetConfig, + EHCacheConfig resultConfig) { _cachemgr = cachemgr; - createEHCache(ident, CacheCategory.RECORD, EHCACHE_RECORD_CONFIG); - createEHCache(ident, CacheCategory.SHORT_KEYSET, EHCACHE_SHORT_KEYSET_CONFIG); - createEHCache(ident, CacheCategory.LONG_KEYSET, EHCACHE_LONG_KEYSET_CONFIG); - createEHCache(ident, CacheCategory.RESULT, EHCACHE_RESULT_CONFIG); + createEHCache(ident, CacheCategory.RECORD, recordConfig); + createEHCache(ident, CacheCategory.SHORT_KEYSET, shortKeySetConfig); + createEHCache(ident, CacheCategory.LONG_KEYSET, longKeySetConfig); + createEHCache(ident, CacheCategory.RESULT, resultConfig); } // from CacheAdapter