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
*/
_manager = CacheManager.create();
_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();
}
*/
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);
}