/** * Removes an entry from the cache.<p> * * @param key the key which describes the entry to remove from the cache */ void remove(CmsFlexCacheKey key) { if (!isEnabled()) { return; } CmsFlexCacheVariation o = m_keyCache.get(key.getResource()); if (o != null) { I_CmsLruCacheObject old = o.m_map.get(key.getVariation()); if (old != null) { getEntryLruCache().remove(old); } } }
/** * Clears the cache for finalization.<p> * @throws Throwable if something goes wrong */ @Override protected void finalize() throws Throwable { try { clear(); } catch (Throwable t) { // ignore } super.finalize(); }
/** * Clears all entries from offline projects in the cache.<p> * * The keys from the offline projects are not cleared. * Cached resources from the online project are not touched.<p> * * Only users with administrator permissions are allowed * to perform this operation.<p> */ private void clearOfflineEntries() { if (!isEnabled()) { return; } if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_CLEAR_OFFLINE_ENTRIES_0)); } clearAccordingToSuffix(CACHE_OFFLINESUFFIX, true); }
if (!isEnabled()) { return; clear(); break; case I_CmsEventListener.EVENT_FLEX_PURGE_JSP_REPOSITORY: purgeJspRepository(); break; case I_CmsEventListener.EVENT_FLEX_CACHE_CLEAR: switch (i) { case CLEAR_ALL: clear(); break; case CLEAR_ENTRIES: clearEntries(); break; case CLEAR_ONLINE_ALL: clearOnline(); break; case CLEAR_ONLINE_ENTRIES: clearOnlineEntries(); break; case CLEAR_OFFLINE_ALL: clearOffline(); break; case CLEAR_OFFLINE_ENTRIES: clearOfflineEntries();
/** * Initializes the cache object.<p> */ protected void initCacheObject() { CmsFlexController controller = (CmsFlexController)getJsp().getRequest().getAttribute( CmsFlexController.ATTRIBUTE_NAME); CmsFlexCache cache = controller.getCmsCache(); setVariations("" + cache.size()); setKeys("" + cache.keySize()); CmsLruCache entryLruCache = cache.getEntryLruCache(); if (entryLruCache != null) { Locale locale = getLocale(); setMaxSize(CmsFileUtil.formatFilesize(entryLruCache.getMaxCacheCosts(), locale)); setAvgSize(CmsFileUtil.formatFilesize(entryLruCache.getAvgCacheCosts(), locale)); setCurSize(CmsFileUtil.formatFilesize(entryLruCache.getObjectCosts(), locale)); } }
m_canCache = ((((m_isOnline && m_controller.getCmsCache().isEnabled()) || (!m_isOnline && m_controller.getCmsCache().cacheOffline())) && !nocachepara) || dorecompile); m_doRecompile = dorecompile; if (LOG.isDebugEnabled()) {
if (cache.cacheOffline()) { n = 2;
flexCache = new CmsFlexCache(flexCacheConfiguration); if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_FLEX_CACHE_FINISHED_0));
if (!isEnabled()) { return; clear(); break; case I_CmsEventListener.EVENT_FLEX_PURGE_JSP_REPOSITORY: purgeJspRepository(); break; case I_CmsEventListener.EVENT_FLEX_CACHE_CLEAR: switch (i) { case CLEAR_ALL: clear(); break; case CLEAR_ENTRIES: clearEntries(); break; case CLEAR_ONLINE_ALL: clearOnline(); break; case CLEAR_ONLINE_ENTRIES: clearOnlineEntries(); break; case CLEAR_OFFLINE_ALL: clearOffline(); break; case CLEAR_OFFLINE_ENTRIES: clearOfflineEntries();
m_canCache = (((m_isOnline || m_controller.getCmsCache().cacheOffline()) && !nocachepara) || dorecompile); m_doRecompile = dorecompile; if (LOG.isDebugEnabled()) {
getSystemInfo().setDeviceSelector(flexCacheConfiguration.getDeviceSelector()); flexCache = new CmsFlexCache(flexCacheConfiguration); if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_FLEX_CACHE_FINISHED_0));
/** * Clears all entries from the online project in the cache.<p> * * The keys from the online project are not cleared. * Cached resources from the offline projects are not touched.<p> * * Only users with administrator permissions are allowed * to perform this operation.<p> */ private void clearOnlineEntries() { if (!isEnabled()) { return; } if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_CLEAR_ONLINE_ENTRIES_0)); } clearAccordingToSuffix(CACHE_ONLINESUFFIX, true); }
/** * Removes an entry from the cache.<p> * * @param key the key which describes the entry to remove from the cache */ void remove(CmsFlexCacheKey key) { if (!isEnabled()) { return; } Object o = m_keyCache.get(key.getResource()); if (o != null) { //Object old = ((HashMap)o).remove(key.Variation); Object old = ((HashMap)o).get(key.getVariation()); if (old != null) { getEntryLruCache().remove((I_CmsLruCacheObject)old); } } }
/** * Creates the list of widgets for this dialog.<p> */ @Override protected void defineWidgets() { setKeyPrefix(KEY_PREFIX); // initialize the cache object to use for the dialog CmsFlexController controller = (CmsFlexController)getJsp().getRequest().getAttribute( CmsFlexController.ATTRIBUTE_NAME); CmsFlexCache cache = controller.getCmsCache(); setOffline(true); setOnline(true); setMode(MODE_ALL); // widgets to display if (cache.cacheOffline()) { addWidget(new CmsWidgetDialogParameter(this, "offline", PAGES[0], new CmsCheckboxWidget())); } addWidget(new CmsWidgetDialogParameter(this, "online", PAGES[0], new CmsCheckboxWidget())); addWidget(new CmsWidgetDialogParameter(this, "mode", PAGES[0], new CmsRadioSelectWidget(getModes()))); }
/** * This method purges the JSP repository dirs, * i.e. it deletes all JSP files that OpenCms has written to the * real FS.<p> * * Obviously this method must be used with caution. * Purpose of this method is to allow * a complete purge of all JSP pages on a machine after * a major update of JSP templates was made.<p> */ private synchronized void purgeJspRepository() { if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_WILL_PURGE_JSP_REPOSITORY_0)); } File d; d = new File(org.opencms.loader.CmsJspLoader.getJspRepository() + REPOSITORY_ONLINE + File.separator); CmsFileUtil.purgeDirectory(d); d = new File(org.opencms.loader.CmsJspLoader.getJspRepository() + REPOSITORY_OFFLINE + File.separator); CmsFileUtil.purgeDirectory(d); clear(); if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_PURGED_JSP_REPOSITORY_0)); } }
/** * Clears all entries and all keys from offline projects in the cache.<p> * * Cached resources from the online project are not touched.<p> * * Only users with administrator permissions are allowed * to perform this operation.<p> */ private void clearOffline() { if (!isEnabled()) { return; } if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_CLEAR_KEYS_AND_ENTRIES_0)); } clearAccordingToSuffix(CACHE_OFFLINESUFFIX, false); }
/** * Clears all entries and all keys from the online project in the cache.<p> * * Cached resources from the offline projects are not touched.<p> * * Only users with administrator permissions are allowed * to perform this operation.<p> */ private void clearOnline() { if (!isEnabled()) { return; } if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_CLEAR_ONLINE_KEYS_AND_ENTRIES_0)); } clearAccordingToSuffix(CACHE_ONLINESUFFIX, false); }
/** * Clears all entries and all keys from offline projects in the cache.<p> * * Cached resources from the online project are not touched.<p> * * Only users with administrator permissions are allowed * to perform this operation.<p> */ private void clearOffline() { if (!isEnabled()) { return; } if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_CLEAR_KEYS_AND_ENTRIES_0)); } clearAccordingToSuffix(CACHE_OFFLINESUFFIX, false); }
/** * Clears all entries and all keys from the online project in the cache.<p> * * Cached resources from the offline projects are not touched.<p> * * Only users with administrator permissions are allowed * to perform this operation.<p> */ private void clearOnline() { if (!isEnabled()) { return; } if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_CLEAR_ONLINE_KEYS_AND_ENTRIES_0)); } clearAccordingToSuffix(CACHE_ONLINESUFFIX, false); }
/** * Clears all entries from offline projects in the cache.<p> * * The keys from the offline projects are not cleared. * Cached resources from the online project are not touched.<p> * * Only users with administrator permissions are allowed * to perform this operation.<p> */ private void clearOfflineEntries() { if (!isEnabled()) { return; } if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_CLEAR_OFFLINE_ENTRIES_0)); } clearAccordingToSuffix(CACHE_OFFLINESUFFIX, true); }