LOG.info("Creating EhCache cache instance");
int maxCacheSize = getIntConfigurationValue(facesContext, CoreConfiguration.Items.resourcesCacheSize);
boolean preconfiguredCache = false;
Ehcache ehcache = cacheManager.getEhcache(cacheName);
if (ehcache == null) {
ehcache = new net.sf.ehcache.Cache(cacheName, maxCacheSize, false, true, 0, 0);
} else {
preconfiguredCache = true;
if (ehcache.getCacheConfiguration().getMaxEntriesLocalHeap() <= 0) {
LOG.info(MessageFormat.format("Maximum cache size hasn''t been set, resetting to {0} max items", maxCacheSize));
ehcache.getCacheConfiguration().setMaxEntriesLocalHeap(maxCacheSize);
}
}
ehcache.setCacheManager(cacheManager);
return new EhCacheCache(ehcache, preconfiguredCache);
}