/** * This delivers cached sub-elements back to the stream. * Needed to overcome JSP buffering.<p> * * @param res the response to write the cached results to * * @throws IOException in case something goes wrong writing to the responses output stream */ private void writeCachedResultToStream(HttpServletResponse res) throws IOException { List elements = m_cachedEntry.elements(); int count = 0; if (elements != null) { for (int i = 0; i < elements.size(); i++) { Object o = elements.get(i); if (o instanceof byte[]) { res.getOutputStream().write((byte[])o); } else { if ((m_includeResults != null) && (m_includeResults.size() > count)) { // make sure that we don't run behind end of list (should never happen, though) res.getOutputStream().write((byte[])m_includeResults.get(count)); count++; } // skip next entry, which is the parameter list for this include call i++; } } } } }
/** * @see org.opencms.monitor.I_CmsMemoryMonitorable#getMemorySize() */ public int getMemorySize() { return getLruCacheCosts(); }
/** * Sets an expiration date for this cache entry to the next timeout, * which indicates the time this entry becomes invalid.<p> * * The timeout parameter represents the minute - interval in which the cache entry * is to be cleared. * The interval always starts at 0.00h. * A value of 60 would indicate that this entry will reach it's expiration date at the beginning of the next * full hour, a timeout of 20 would indicate that the entry is invalidated at x.00, x.20 and x.40 of every hour etc.<p> * * @param timeout the timeout value to be set */ public void setDateExpiresToNextTimeout(long timeout) { if ((timeout < 0) || !m_completed) { return; } long now = System.currentTimeMillis(); long daytime = now % 86400000; long timeoutMinutes = timeout * 60000; setDateExpires((now - (daytime % timeoutMinutes)) + timeoutMinutes); }
m_vfsTarget)); controller.updateDates(entry.getDateLastModified(), entry.getDateExpires()); entry.service(w_req, w_res); } catch (CmsException e) { Throwable t; entry.setDateLastModifiedToPreviousTimeout(w_res.getCmsCacheKey().getTimeout()); entry.setDateExpiresToNextTimeout(w_res.getCmsCacheKey().getTimeout()); controller.updateDates(entry.getDateLastModified(), entry.getDateExpires()); } else { entry.setDateLastModified(controller.getDateLastModified()); entry.setDateExpires(controller.getDateExpires());
m_cachedEntry = new CmsFlexCacheEntry(); if (m_bufferRedirect != null) { m_cachedEntry.setRedirect(m_bufferRedirect, m_redirectPermanent); } else { m_cachedEntry.addHeaders(m_bufferHeaders); } else { m_cachedEntry.add(getWriterBytes()); m_cachedEntry.complete();
if (entry.getDateExpires() < System.currentTimeMillis()) {
if (!hasIncludeList()) { m_cachedEntry.add(result); } else { System.arraycopy(result, last, piece, 0, size); m_cachedEntry.add(piece); piece = null; m_cachedEntry.add((String)m_includeList.get(i++), (Map)m_includeListParameters.get(j++)); byte[] piece = new byte[size]; System.arraycopy(result, pos, piece, 0, size); m_cachedEntry.add(piece); piece = null;
m_vfsTarget)); controller.updateDates(entry.getDateLastModified(), entry.getDateExpires()); entry.service(w_req, w_res); } catch (CmsException e) { Throwable t; entry.setDateLastModifiedToPreviousTimeout(w_res.getCmsCacheKey().getTimeout()); entry.setDateExpiresToNextTimeout(w_res.getCmsCacheKey().getTimeout()); controller.updateDates(entry.getDateLastModified(), entry.getDateExpires()); } else { entry.setDateLastModified(controller.getDateLastModified()); entry.setDateExpires(controller.getDateExpires());
m_cachedEntry = new CmsFlexCacheEntry(); if (m_bufferRedirect != null) { m_cachedEntry.setRedirect(m_bufferRedirect); } else { m_cachedEntry.addHeaders(m_bufferHeaders); } else { m_cachedEntry.add(getWriterBytes()); m_cachedEntry.complete();
if (entry.getDateExpires() < System.currentTimeMillis()) {
if (!hasIncludeList()) { m_cachedEntry.add(result); } else { System.arraycopy(result, last, piece, 0, size); m_cachedEntry.add(piece); piece = null; m_cachedEntry.add( m_includeList.get(i), m_includeListParameters.get(i), byte[] piece = new byte[size]; System.arraycopy(result, pos, piece, 0, size); m_cachedEntry.add(piece); piece = null;
/** * @see org.opencms.monitor.I_CmsMemoryMonitorable#getMemorySize() */ public int getMemorySize() { return getLruCacheCosts(); }
/** * Sets an expiration date for this cache entry to the next timeout, * which indicates the time this entry becomes invalid.<p> * * The timeout parameter represents the minute - interval in which the cache entry * is to be cleared. * The interval always starts at 0.00h. * A value of 60 would indicate that this entry will reach it's expiration date at the beginning of the next * full hour, a timeout of 20 would indicate that the entry is invalidated at x.00, x.20 and x.40 of every hour etc.<p> * * @param timeout the timeout value to be set */ public void setDateExpiresToNextTimeout(long timeout) { if ((timeout < 0) || !m_completed) { return; } long now = System.currentTimeMillis(); long daytime = now % 86400000; long timeoutMinutes = timeout * 60000; setDateExpires(now - (daytime % timeoutMinutes) + timeoutMinutes); }
List<Object> elements = m_cachedEntry.elements(); int count = 0; if (elements != null) {
/** * @see java.lang.Object#toString() * * @return a basic String representation of this CmsFlexCache entry */ @Override public String toString() { String str = null; if (m_redirectTarget == null) { str = "CmsFlexCacheEntry [" + m_elements.size() + " Elements/" + getLruCacheCosts() + " bytes]\n"; Iterator<Object> i = m_elements.iterator(); int count = 0; while (i.hasNext()) { count++; Object o = i.next(); if (o instanceof String) { str += "" + count + " - <cms:include target=" + o + ">\n"; } else if (o instanceof byte[]) { str += "" + count + " - <![CDATA[" + new String((byte[])o) + "]]>\n"; } else { str += "<!--[" + o.toString() + "]-->"; } } } else { str = "CmsFlexCacheEntry [Redirect to target=" + m_redirectTarget + "]"; } return str; }
/** * @see java.lang.Object#toString() * * @return a basic String representation of this CmsFlexCache entry */ @Override public String toString() { String str = null; if (m_redirectTarget == null) { str = "CmsFlexCacheEntry [" + m_elements.size() + " Elements/" + getLruCacheCosts() + " bytes]\n"; Iterator i = m_elements.iterator(); int count = 0; while (i.hasNext()) { count++; Object o = i.next(); if (o instanceof String) { str += "" + count + " - <cms:include target=" + o + ">\n"; } else if (o instanceof byte[]) { str += "" + count + " - <![CDATA[" + new String((byte[])o) + "]]>\n"; } else { str += "<!--[" + o.toString() + "]-->"; } } } else { str = "CmsFlexCacheEntry [Redirect to target=" + m_redirectTarget + "]"; } return str; } }