(no commit message)
[utils] / support / src / org / wamblee / cache / EhCache.java
index 4f56cd3a0fd74dc203c5aa91da49989a8b8b6dc8..ca11ab3f72c71f13aa92341afb6f5ba13fd064e2 100644 (file)
@@ -35,23 +35,25 @@ public class EhCache<KeyType extends Serializable, ValueType extends Serializabl
         implements org.wamblee.cache.Cache<KeyType, ValueType> {
 
     private static final Logger LOGGER = Logger.getLogger(EhCache.class);
-    
+
     /**
-     * EH Cache manager. 
+     * EH Cache manager.
      */
     private CacheManager _manager;
 
     /**
-     * EH cache. 
+     * EH cache.
      */
     private Cache _cache;
 
     /**
-     * Constructs a cache based on EHCache. 
-     * @param aResource Resource containing the configuration file for 
-     *    EHCache. 
-     * @param aCacheName Name of the cache to use. If a cache with this name does 
-     *    not exist, one is created based on default settings. 
+     * Constructs a cache based on EHCache.
+     * 
+     * @param aResource
+     *            Resource containing the configuration file for EHCache.
+     * @param aCacheName
+     *            Name of the cache to use. If a cache with this name does not
+     *            exist, one is created based on default settings.
      * @throws IOException
      * @throws CacheException
      */
@@ -59,14 +61,15 @@ public class EhCache<KeyType extends Serializable, ValueType extends Serializabl
             throws IOException, CacheException {
         InputStream is = aResource.getInputStream();
         try {
-            _manager = CacheManager.create();
+            _manager = CacheManager.create(is);
             _cache = _manager.getCache(aCacheName);
             if (_cache == null) {
-                LOGGER.warn("Creating cache '" + aCacheName + "' because it is not configured");;
+                LOGGER.warn("Creating cache '" + aCacheName
+                        + "' because it is not configured");
                 _manager.addCache(aCacheName);
                 _cache = _manager.getCache(aCacheName);
             }
-            assert _cache != null; 
+            assert _cache != null;
         } finally {
             is.close();
         }
@@ -89,11 +92,11 @@ public class EhCache<KeyType extends Serializable, ValueType extends Serializabl
      */
     public ValueType get(KeyType aKey) {
         try {
-            Element element =  _cache.get(aKey);
-            if ( element == null ) { 
-                return null; 
+            Element element = _cache.get(aKey);
+            if (element == null) {
+                return null;
             }
-            return (ValueType)element.getValue();
+            return (ValueType) element.getValue();
         } catch (CacheException e) {
             throw new RuntimeException("Cache problem key = '" + aKey + "'", e);
         }