@Create
public void startup() throws Exception {
log.info("starting wiki page fragment cache regions");
try {
CacheManager manager = EHCacheManager.instance();
Set<String> requiredCacheRegions = new HashSet<String>();
if (cacheRegions != null) {
requiredCacheRegions.addAll(cacheRegions);
}
PluginRegistry pluginRegistry = PluginRegistry.instance();
for (Plugin plugin : pluginRegistry.getPlugins()) {
for (PluginModule pluginModule : plugin.getModules()) {
if (pluginModule.getFragmentCacheRegions() != null)
requiredCacheRegions.addAll(pluginModule.getFragmentCacheRegions());
}
}
for (String cacheRegion : requiredCacheRegions) {
Cache cache = EHCacheManager.instance().getCache(cacheRegion);
if (cache == null) {
log.info("using default configuration for region '" + cacheRegion + "'");
manager.addCache(cacheRegion);
cache = manager.getCache(cacheRegion);
log.debug("started EHCache region: " + cacheRegion);
}
caches.put(cacheRegion, cache);
}