net.sf.ehcache.constructs.web.filter
Class PageFragmentCachingFilter
java.lang.Object
net.sf.ehcache.constructs.web.filter.Filter
net.sf.ehcache.constructs.web.filter.CachingFilter
net.sf.ehcache.constructs.web.filter.PageFragmentCachingFilter
- All Implemented Interfaces:
- javax.servlet.Filter
- Direct Known Subclasses:
- SimplePageFragmentCachingFilter
public abstract class PageFragmentCachingFilter
- extends CachingFilter
A Template for a page caching filter that is designed for "included" pages, eg: jsp:includes. This filter
differs from the CachingFilter
in that it is not writing an entire response to the output stream.
This class should be sub-classed for each included page to be cached.
Filter Mappings need to be set up for a cache to have effect.
- Version:
- $Id: PageFragmentCachingFilter.java 70 2006-05-07 11:50:02Z gregluck $
- Author:
- Greg Luck
Method Summary |
protected PageInfo |
buildPage(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain chain)
Builds the PageInfo object by passing the request along the filter chain |
protected void |
doFilter(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain chain)
Performs the filtering for a request. |
protected void |
writeResponse(javax.servlet.http.HttpServletResponse response,
PageInfo pageInfo)
Assembles a response from a cached page include. |
Methods inherited from class net.sf.ehcache.constructs.web.filter.CachingFilter |
buildPageInfo, calculateKey, checkNoReentry, doDestroy, doInit, getCacheManager, getCacheName, setContentType, setCookies, setHeaders, setStatus, writeContent, writeResponse |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PageFragmentCachingFilter
public PageFragmentCachingFilter()
doFilter
protected void doFilter(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain chain)
throws java.lang.Exception
- Performs the filtering for a request.
- Overrides:
doFilter
in class CachingFilter
- Throws:
AlreadyGzippedException
- if a double gzip is attempted
AlreadyCommittedException
- if the response was committed on the way in or the on the way back
FilterNonReentrantException
- if an attempt is made to reenter this filter in the same request.
LockTimeoutException
- if this request is waiting on another that is populating the cache entry
and timeouts while waiting. Only occurs if the BlockingCache has a timeout set.
java.lang.Exception
- for all other exceptions. They will be caught and logged in
Filter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
buildPage
protected PageInfo buildPage(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain chain)
throws AlreadyGzippedException,
java.lang.Exception
- Builds the PageInfo object by passing the request along the filter chain
- Overrides:
buildPage
in class CachingFilter
- Parameters:
request
- response
- chain
-
- Returns:
- a Serializable value object for the page or page fragment
- Throws:
AlreadyGzippedException
- if an attempt is made to double gzip the body
java.lang.Exception
writeResponse
protected void writeResponse(javax.servlet.http.HttpServletResponse response,
PageInfo pageInfo)
throws java.io.IOException
- Assembles a response from a cached page include.
These responses are never gzipped
The content length should not be set in the response, because it is a fragment of a page.
Don't write any headers at all.
- Throws:
java.io.IOException