Search in sources :

Example 1 with CacheException

use of org.xwiki.cache.CacheException in project xwiki-platform by xwiki.

the class ParseGroovyFromString method initCache.

private void initCache(int iClassCapacity, XWikiContext context) throws XWikiException {
    try {
        CacheConfiguration configuration = new LRUCacheConfiguration("xwiki.groovy.class", iClassCapacity);
        this.classCache = this.cacheManager.createNewLocalCache(configuration);
    } catch (CacheException e) {
        throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to initilize caches", e);
    }
}
Also used : CacheException(org.xwiki.cache.CacheException) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration) LRUCacheConfiguration(org.xwiki.cache.config.LRUCacheConfiguration) XWikiException(com.xpn.xwiki.XWikiException) LRUCacheConfiguration(org.xwiki.cache.config.LRUCacheConfiguration)

Example 2 with CacheException

use of org.xwiki.cache.CacheException in project xwiki-platform by xwiki.

the class XWikiCacheServiceStub method newCache.

@Override
public XWikiCache newCache(String cacheName, int capacity) throws XWikiException {
    CacheConfiguration configuration = new CacheConfiguration();
    configuration.setConfigurationId(cacheName);
    LRUEvictionConfiguration lru = new LRUEvictionConfiguration();
    lru.setMaxEntries(capacity);
    configuration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru);
    try {
        return new XWikiCacheStub(this.cacheFactory.newCache(configuration));
    } catch (CacheException e) {
        throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to create new cache", e);
    }
}
Also used : CacheException(org.xwiki.cache.CacheException) LRUEvictionConfiguration(org.xwiki.cache.eviction.LRUEvictionConfiguration) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration) XWikiException(com.xpn.xwiki.XWikiException)

Example 3 with CacheException

use of org.xwiki.cache.CacheException in project xwiki-platform by xwiki.

the class DefaultOfficeResourceViewer method initialize.

@Override
public void initialize() throws InitializationException {
    try {
        LRUCacheConfiguration attachmentConfig = new LRUCacheConfiguration(MODULE_NAME + ".attachment", 50);
        this.attachmentCache = this.cacheManager.createNewCache(attachmentConfig);
        // We have no idea when to invalidate the cache so lets at least put a time to live
        LRUCacheConfiguration exteralConfig = new LRUCacheConfiguration(MODULE_NAME + ".external", 50, 3600);
        this.externalCache = this.cacheManager.createNewCache(exteralConfig);
    } catch (CacheException e) {
        throw new InitializationException("Failed to create caches.", e);
    }
}
Also used : CacheException(org.xwiki.cache.CacheException) InitializationException(org.xwiki.component.phase.InitializationException) LRUCacheConfiguration(org.xwiki.cache.config.LRUCacheConfiguration)

Example 4 with CacheException

use of org.xwiki.cache.CacheException 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");
    }
}
Also used : CacheException(org.xwiki.cache.CacheException) LRUEvictionConfiguration(org.xwiki.cache.eviction.LRUEvictionConfiguration) CacheManager(org.xwiki.cache.CacheManager) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration) XWikiException(com.xpn.xwiki.XWikiException)

Example 5 with CacheException

use of org.xwiki.cache.CacheException 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);
}
Also used : CacheException(org.xwiki.cache.CacheException) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration)

Aggregations

CacheException (org.xwiki.cache.CacheException)17 CacheConfiguration (org.xwiki.cache.config.CacheConfiguration)15 InitializationException (org.xwiki.component.phase.InitializationException)8 LRUEvictionConfiguration (org.xwiki.cache.eviction.LRUEvictionConfiguration)7 XWikiException (com.xpn.xwiki.XWikiException)6 CacheFactory (org.xwiki.cache.CacheFactory)4 LRUCacheConfiguration (org.xwiki.cache.config.LRUCacheConfiguration)3 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)3 List (java.util.List)1 Test (org.junit.Test)1 CacheManager (org.xwiki.cache.CacheManager)1 MacroExecutionException (org.xwiki.rendering.macro.MacroExecutionException)1