use of org.xwiki.cache.config.CacheConfiguration in project xwiki-platform by xwiki.
the class FeedPlugin method initCache.
public void initCache(int iCapacity, XWikiContext context) throws XWikiException {
try {
CacheConfiguration configuration = new CacheConfiguration();
configuration.setConfigurationId("xwiki.plugin.feedcache");
LRUEvictionConfiguration lru = new LRUEvictionConfiguration();
lru.setMaxEntries(iCapacity);
lru.setMaxIdle(this.refreshPeriod);
configuration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru);
CacheManager cacheManager = Utils.getComponent(CacheManager.class);
this.feedCache = cacheManager.createNewLocalCache(configuration);
} catch (CacheException e) {
throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to create cache");
}
}
use of org.xwiki.cache.config.CacheConfiguration in project xwiki-platform by xwiki.
the class DocumentTranslationBundleFactory method initialize.
@Override
public void initialize() throws InitializationException {
// Cache
CacheConfiguration cacheConfiguration = new CacheConfiguration("localization.bundle.document");
try {
this.onDemandBundleCache = this.cacheManager.createNewCache(cacheConfiguration);
} catch (CacheException e) {
this.logger.error("Failed to create cache [{}]", cacheConfiguration.getConfigurationId(), e);
}
// Load existing translations from main wiki, wait for WikiReaderEvent for other wikis
loadTranslations(this.wikiManager.getMainWikiId());
// Listeners
this.observation.addListener(this.listener);
this.observation.addListener(this.wikilistener);
}
use of org.xwiki.cache.config.CacheConfiguration in project xwiki-platform by xwiki.
the class DefaultSecurityCache method newCache.
/**
* @return a new configured security cache
* @throws InitializationException if a CacheException arise during creation
*/
private Cache<SecurityCacheEntry> newCache() throws InitializationException {
CacheConfiguration cacheConfig = new CacheConfiguration();
cacheConfig.setConfigurationId("platform.security.authorization.cache");
LRUEvictionConfiguration lru = new LRUEvictionConfiguration();
lru.setMaxEntries(DEFAULT_CAPACITY);
cacheConfig.put(LRUEvictionConfiguration.CONFIGURATIONID, lru);
try {
return cacheManager.createNewCache(cacheConfig);
} catch (Exception e) {
throw new InitializationException(String.format("Unable to create the security cache with a capacity of [%d] entries", lru.getMaxEntries()), e);
}
}
use of org.xwiki.cache.config.CacheConfiguration in project xwiki-platform by xwiki.
the class DefaultColorThemeCache method initialize.
@Override
public void initialize() throws InitializationException {
try {
// Create the cache
CacheConfiguration configuration = new CacheConfiguration(LESS_COLOR_THEMES_CACHE_ID);
CacheFactory cacheFactory = cacheManager.getCacheFactory();
super.cache = cacheFactory.newCache(configuration);
// The Color Theme only depends on colors which do not depend on the XWikiContext. So we don't handle the
// XWikiContext in this cache.
super.isContextHandled = false;
} catch (ComponentLookupException | CacheException e) {
throw new InitializationException(String.format("Failed to initialize LESS color themes cache [%s].", LESS_COLOR_THEMES_CACHE_ID), e);
}
}
use of org.xwiki.cache.config.CacheConfiguration in project xwiki-platform by xwiki.
the class DefaultLESSResourcesCache method initialize.
@Override
public void initialize() throws InitializationException {
try {
CacheConfiguration configuration = new CacheConfiguration(LESS_FILES_CACHE_ID);
CacheFactory cacheFactory = cacheManager.getCacheFactory();
this.cache = cacheFactory.newCache(configuration);
} catch (ComponentLookupException | CacheException e) {
throw new InitializationException(String.format("Failed to initialize LESS skin files cache [%s].", LESS_FILES_CACHE_ID), e);
}
}
Aggregations