public XWikiCache newLocalCache() throws XWikiException { try { return new XWikiCacheStub(this.localCacheFactory.newCache(new CacheConfiguration())); } catch (CacheException e) { throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to create new cache", e); } }
private Cache<DefaultWikiDescriptor> createCache(String cacheId) throws InitializationException { CacheConfiguration configuration = new CacheConfiguration(cacheId); try { return this.cacheManager.createNewCache(configuration); } catch (CacheException e) { throw new InitializationException( String.format("Failed to initialize wiki descriptor caches [%s]", configuration.getConfigurationId()), e); } }
@Override public void initialize() throws InitializationException { try { CacheConfiguration configuration = new CacheConfiguration(CACHE_NAME); CacheFactory cacheFactory = cacheManager.getCacheFactory(); this.cache = cacheFactory.newCache(configuration); } catch (ComponentLookupException | CacheException e) { throw new InitializationException( String.format("Failed to initialize the notification filters preferences cache [%s].", CACHE_NAME), e); } }
@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); } } }
@Override public void initialize() throws InitializationException { try { CacheConfiguration configuration = new CacheConfiguration(LESS_COLOR_THEMES_CACHE_ID); CacheFactory cacheFactory = cacheManager.getCacheFactory(); this.cache = cacheFactory.newCache(configuration); } catch (ComponentLookupException | CacheException e) { throw new InitializationException( String.format("Failed to initialize LESS color themes cache [%s].", LESS_COLOR_THEMES_CACHE_ID), e); } } }
@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); } } }
@Override public void initialize() throws InitializationException { try { CacheConfiguration configuration = new CacheConfiguration(ICON_SET_CACHE_ID); CacheFactory cacheFactory = cacheManager.getCacheFactory(); this.cache = cacheFactory.newCache(configuration); } catch (ComponentLookupException | CacheException e) { throw new InitializationException("Failed to initialize the IconSet Cache.", e); } }
@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); } } }
public XWikiCache newCache(String cacheName) throws XWikiException { CacheConfiguration configuration = new CacheConfiguration(); configuration.setConfigurationId(cacheName); 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); } }
@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); }
@Override public void initialize() throws InitializationException { try { this.server = new HttpSolrServer("http://localhost:8080/solr/" + this.getName() + "/"); this.cache = this.cacheFactory.createNewLocalCache(new CacheConfiguration()); } catch (RuntimeException ex) { throw new InitializationException("Invalid URL specified for the Solr server: {}"); } catch (final CacheException ex) { throw new InitializationException("Cannot create cache: " + ex.getMessage()); } }
@Override public void initialize(String serverName) throws InitializationException { try { this.server = new EmbeddedSolrServer(this.cores.getContainer(), serverName); this.cache = this.cacheFactory.createNewLocalCache(new CacheConfiguration()); } catch (RuntimeException ex) { throw new InitializationException("Invalid URL specified for the Solr server: {}"); } catch (final CacheException ex) { throw new InitializationException("Cannot create cache: " + ex.getMessage()); } }
public XWikiCache newLocalCache(int capacity) throws XWikiException { CacheConfiguration configuration = new CacheConfiguration(); LRUEvictionConfiguration lru = new LRUEvictionConfiguration(); lru.setMaxEntries(capacity); configuration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru); try { return new XWikiCacheStub(this.localCacheFactory.newCache(configuration)); } catch (CacheException e) { throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to create new cache", e); } }
/** * @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); } }
/** * @param context the XWiki context used to get cache configuration. * @return the configuration for the LDAP groups cache. */ public static CacheConfiguration getGroupCacheConfiguration(XWikiContext context) { if (cacheConfigurationGroups == null) { XWikiLDAPConfig config = XWikiLDAPConfig.getInstance(); cacheConfigurationGroups = new CacheConfiguration(); cacheConfigurationGroups.setConfigurationId(CACHE_NAME_GROUPS); LRUEvictionConfiguration lru = new LRUEvictionConfiguration(); lru.setTimeToLive(config.getCacheExpiration(context)); cacheConfigurationGroups.put(LRUEvictionConfiguration.CONFIGURATIONID, lru); } return cacheConfigurationGroups; }
/** * Initializes global webdav cache. * * @throws DavException if an error occurs while initializing the cache. */ private static void initCache() throws DavException { try { CacheManager cacheManager = Utils.getComponent(CacheManager.class, "default"); CacheConfiguration conf = new CacheConfiguration(); LRUEvictionConfiguration lec = new LRUEvictionConfiguration(); lec.setMaxIdle(300); conf.put(LRUEvictionConfiguration.CONFIGURATIONID, lec); davCache = cacheManager.createNewCache(conf); } catch (CacheException ex) { throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, ex); } }
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); } }
public void initCache(int iCapacity, XWikiContext context) throws XWikiException { try { CacheConfiguration configuration = new CacheConfiguration(); configuration.setConfigurationId("xwiki.renderingcache"); LRUEvictionConfiguration lru = new LRUEvictionConfiguration(); lru.setMaxEntries(iCapacity); configuration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru); this.cache = context.getWiki().getCacheFactory().newCache(configuration); } catch (CacheException e) { throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to create cache"); } }
/** * {@inheritDoc} * * @see com.xpn.xwiki.user.api.XWikiGroupService#initCache(int, com.xpn.xwiki.XWikiContext) */ public synchronized void initCache(int iCapacity, XWikiContext context) throws XWikiException { try { CacheConfiguration configuration = new CacheConfiguration(); configuration.setConfigurationId("xwiki.groupservice.usergroups"); LRUEvictionConfiguration lru = new LRUEvictionConfiguration(); lru.setMaxEntries(iCapacity); configuration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru); this.memberGroupsCache = Utils.getComponent(CacheManager.class).createNewCache(configuration); } catch (CacheException e) { throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to initialize cache", e); } }
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.setTimeToLive(this.refreshPeriod); configuration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru); this.feedCache = context.getWiki().getLocalCacheFactory().newCache(configuration); } catch (CacheException e) { throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to create cache"); } }