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, String originalUrl, int timeToLiveInSeconds)
           
 
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()
          Produce last modification date of the cache entry.
 String getOriginalURL()
          Entry might be required to produce url used to create it in the first place.
 int getStatusCode()
           
 int getTimeToLiveInSeconds()
           
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,
                          String originalUrl,
                          int timeToLiveInSeconds)
                   throws IOException
Parameters:
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.
timeToLiveInSeconds -
Throws:
IOException - when failing to compress the content.
Method Detail

getOriginalURL

public String getOriginalURL()
Description copied from interface: CachedEntry
Entry might be required to produce url used to create it in the first place.

Specified by:
getOriginalURL in interface CachedEntry
Returns:
URL that triggered cache entry creation.

getContentType

public String getContentType()

getCharacterEncoding

public String getCharacterEncoding()

getStatusCode

public int getStatusCode()

getHeaders

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

getLastModificationTime

public long getLastModificationTime()
Description copied from interface: CachedEntry
Produce last modification date of the cache entry. If no other time can be discerned, the time of entry creation should be returned.

Specified by:
getLastModificationTime in interface CachedEntry
Returns:
time when cached entry was last modified. This time should reflect real modification time of the cached content.

getTimeToLiveInSeconds

public int getTimeToLiveInSeconds()
Specified by:
getTimeToLiveInSeconds in interface CachedEntry

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-2012 Magnolia International Ltd.. All Rights Reserved.