info.magnolia.module.cache.filter
Class ContentCachedEntry

java.lang.Object
  extended by info.magnolia.module.cache.filter.ContentCachedEntry
All Implemented Interfaces:
CachedEntry, Serializable
Direct Known Subclasses:
DelegatingBlobCachedEntry, InMemoryCachedEntry

public abstract class ContentCachedEntry
extends Object
implements CachedEntry, Serializable

Wraps a page response. It is assumed that the given content is gzipped if appropriate (i.e if the gzip filter is in the chain) and this class thus ungzips it to be able to serve both contents.

Version:
$Revision: $ ($Author: $)
Author:
gjoseph
See Also:
Serialized Form

Constructor Summary
ContentCachedEntry(String contentType, String characterEncoding, int statusCode, org.apache.commons.collections.MultiMap headers, long modificationDate)
           
 
Method Summary
protected  void addHeaders(boolean acceptsGzipEncoding, javax.servlet.http.HttpServletResponse response)
          Sets headers in the response object.
protected abstract  boolean canServeGzipContent()
           
 String getCharacterEncoding()
           
 String getContentType()
           
 org.apache.commons.collections.MultiMap getHeaders()
           
 long getLastModificationTime()
           
 int getStatusCode()
           
protected  boolean isAcceptsGzip(javax.servlet.http.HttpServletRequest request)
           
 void replay(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain chain)
           
 String toString()
           
protected abstract  void writeContent(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain chain, boolean acceptsGzipEncoding)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ContentCachedEntry

public ContentCachedEntry(String contentType,
                          String characterEncoding,
                          int statusCode,
                          org.apache.commons.collections.MultiMap headers,
                          long modificationDate)
                   throws IOException
Parameters:
out - Cached content.
contentType - MIME type of the cached content.
characterEncoding - Character encoding of the cached content.
statusCode - HTTP response status code (E.g. 200 - OK);
headers - Additional HTTP headers to be sent when serving this cached content.
modificationDate - Content modification date to set in the response.
shouldCompress - Flag marking this content as desirable to be sent in compressed form (should the client support such compression). Setting this to true means cache entry will contain both, compressed and flat version of the content. Compression is applied here only if content is not gzipped already.
Throws:
IOException - when failing to compress the content.
Method Detail

getContentType

public String getContentType()

getCharacterEncoding

public String getCharacterEncoding()

getStatusCode

public int getStatusCode()

getHeaders

public org.apache.commons.collections.MultiMap getHeaders()

getLastModificationTime

public long getLastModificationTime()

toString

public String toString()
Overrides:
toString in class Object

replay

public void replay(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response,
                   javax.servlet.FilterChain chain)
            throws IOException,
                   javax.servlet.ServletException
Specified by:
replay in interface CachedEntry
chain - a cache entry might want to delegate to the filter chain, see DelegatingBlobCachedEntry.replay(HttpServletRequest, HttpServletResponse, FilterChain)
Throws:
IOException
javax.servlet.ServletException

writeContent

protected abstract void writeContent(javax.servlet.http.HttpServletRequest request,
                                     javax.servlet.http.HttpServletResponse response,
                                     javax.servlet.FilterChain chain,
                                     boolean acceptsGzipEncoding)
                              throws IOException,
                                     javax.servlet.ServletException
Throws:
IOException
javax.servlet.ServletException

addHeaders

protected void addHeaders(boolean acceptsGzipEncoding,
                          javax.servlet.http.HttpServletResponse response)
Sets headers in the response object.


isAcceptsGzip

protected boolean isAcceptsGzip(javax.servlet.http.HttpServletRequest request)

canServeGzipContent

protected abstract boolean canServeGzipContent()


Copyright © 2003-2011 Magnolia International Ltd.. All Rights Reserved.