use of net.sf.ehcache.Ehcache in project simplejpa by appoxy.
the class EhCacheFactory method createCache.
public synchronized EhcacheWrapper createCache(String name) {
if (manager == null) {
throw new CacheException("CacheFactory was not initialized. Call init() before creating a cache.");
}
try {
Cache cache = manager.getCache(name);
if (cache == null) {
log.warning("Could not find a specific ehcache configuration for cache named [" + name + "]; using defaults.");
manager.addCache(name);
cache = manager.getCache(name);
}
Ehcache backingCache = cache;
if (!backingCache.getCacheEventNotificationService().hasCacheEventListeners()) {
if (listeners.size() > 0) {
for (CacheEventListener listener : listeners) {
if (!backingCache.getCacheEventNotificationService().getCacheEventListeners().contains(listener)) {
backingCache.getCacheEventNotificationService().registerListener(listener);
} else {
}
}
}
}
return new EhcacheWrapper(cache);
} catch (net.sf.ehcache.CacheException e) {
throw new CacheException("Could not create cache: " + name, e);
}
}
Aggregations