public class CachingFilter extends Object implements javax.servlet.Filter, CacheManagerListener
| Constructor and Description |
|---|
CachingFilter() |
| Modifier and Type | Method and Description |
|---|---|
void |
cacheManagerDisabled()
cache manager listener method
|
void |
cacheManagerEnabled()
cache manager listener method
|
void |
destroy()
Called by the web container to indicate to a filter that it is being
taken out of service.
|
void |
doFilter(javax.servlet.ServletRequest srequest,
javax.servlet.ServletResponse sresponse,
javax.servlet.FilterChain chain)
The
doFilter method of the Filter is called by the
container each time a request/response pair is passed through the
chain due to a client request for a resource at the end of the chain. |
void |
init(javax.servlet.FilterConfig filterConfig)
Called by the web container to indicate to a filter that it is being
placed into service.
|
public void init(javax.servlet.FilterConfig filterConfig)
throws javax.servlet.ServletException
init in interface javax.servlet.FilterfilterConfig - filter configjavax.servlet.ServletExceptionpublic void doFilter(javax.servlet.ServletRequest srequest,
javax.servlet.ServletResponse sresponse,
javax.servlet.FilterChain chain)
throws IOException,
javax.servlet.ServletException
doFilter method of the Filter is called by the
container each time a request/response pair is passed through the
chain due to a client request for a resource at the end of the chain.
The FilterChain passed in to this method allows the Filter to pass on
the request and response to the next entity in the chain.doFilter in interface javax.servlet.Filtersrequest - the runtime requestsresponse - the runtime responsechain - the filter chain to in the request processingIOException, - ServletException
- First check if this HTTP method permits caching (using helper)
if not, call the downstream filter and return.
- Otherwise, get the key based on the request (using helper).
- Check if we have a response entry in the cache already.
- If there is entry and is valid, write out the response from that
entry.
- create a CachingResponse and CachingOutputStream wrappers and call
the downstream filterIOExceptionjavax.servlet.ServletExceptionpublic void cacheManagerEnabled()
cacheManagerEnabled in interface CacheManagerListenerpublic void cacheManagerDisabled()
cacheManagerDisabled in interface CacheManagerListenerpublic void destroy()
destroy in interface javax.servlet.FilterCopyright © 2019. All rights reserved.