com.caucho.server.cache
Class CacheFilterChain

java.lang.Object
  extended by com.caucho.server.dispatch.AbstractFilterChain
      extended by com.caucho.server.cache.AbstractCacheFilterChain
          extended by com.caucho.server.cache.CacheFilterChain
All Implemented Interfaces:
CometFilterChain, CacheListener, FilterChain

public class CacheFilterChain
extends AbstractCacheFilterChain
implements CacheListener

Represents the final servlet in a filter chain.


Constructor Summary
CacheFilterChain(Cache cache, FilterChain next, WebApp webApp)
          Create the filter chain servlet.
CacheFilterChain(FilterChain next, WebApp webApp)
          Create the filter chain servlet.
 
Method Summary
 void clearExpires()
          Clears the expires timers
 void doFilter(ServletRequest request, ServletResponse response)
          Handles caching for the filter.
 boolean doResume(ServletRequest request, ServletResponse response)
          Resumes the request.
 boolean fillFromCache(CauchoRequest req, AbstractHttpResponse response, AbstractCacheEntry abstractEntry, boolean isTop)
          fillFromCache is called when the client needs the entire result, and the result is already in the cache.
 void finishCaching(AbstractCacheEntry requestEntry)
          Update the headers when the caching has finished.
 long getHitCount()
           
 java.lang.String getUri()
           
 WebApp getWebApp()
           
 boolean isTop(boolean isTop)
          True for top-level requests.
 void killCaching(AbstractCacheEntry loadingEntry)
          Update the headers when the caching has finished.
 void removeEvent()
          Callback when the item has been removed from the cache, usually because of an LRU event.
 void setTop(boolean isTop)
          True for top-level requests.
 AbstractCacheEntry startCaching(CauchoRequest req, AbstractHttpResponse res, java.util.ArrayList<java.lang.String> keys, java.util.ArrayList<java.lang.String> values, java.lang.String contentType, java.lang.String charEncoding, long contentLength)
          Starts the caching after the headers have been sent.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CacheFilterChain

public CacheFilterChain(FilterChain next,
                        WebApp webApp)
Create the filter chain servlet.


CacheFilterChain

public CacheFilterChain(Cache cache,
                        FilterChain next,
                        WebApp webApp)
Create the filter chain servlet.

Method Detail

setTop

public void setTop(boolean isTop)
True for top-level requests.


isTop

public boolean isTop(boolean isTop)
True for top-level requests.


getHitCount

public long getHitCount()

getWebApp

public WebApp getWebApp()

getUri

public java.lang.String getUri()

clearExpires

public void clearExpires()
Clears the expires timers


doFilter

public void doFilter(ServletRequest request,
                     ServletResponse response)
              throws ServletException,
                     java.io.IOException
Handles caching for the filter.

Specified by:
doFilter in interface FilterChain
Parameters:
req - the servlet request
res - the servlet response
Throws:
ServletException
java.io.IOException

doResume

public boolean doResume(ServletRequest request,
                        ServletResponse response)
                 throws ServletException,
                        java.io.IOException
Resumes the request.

Specified by:
doResume in interface CometFilterChain
Overrides:
doResume in class AbstractFilterChain
Parameters:
request - the servlet request
response - the servlet response
Returns:
true for keepalive, false for the end of the request
Throws:
ServletException
java.io.IOException
Since:
Resin 3.1.3

fillFromCache

public boolean fillFromCache(CauchoRequest req,
                             AbstractHttpResponse response,
                             AbstractCacheEntry abstractEntry,
                             boolean isTop)
                      throws java.io.IOException
fillFromCache is called when the client needs the entire result, and the result is already in the cache.

Specified by:
fillFromCache in class AbstractCacheFilterChain
Parameters:
req - the servlet request trying to get data from the cache
response - the servlet response which will receive data
entry - the cache entry to use
isTop - if true, the not-modified should be sent to the browser
Throws:
java.io.IOException

startCaching

public AbstractCacheEntry startCaching(CauchoRequest req,
                                       AbstractHttpResponse res,
                                       java.util.ArrayList<java.lang.String> keys,
                                       java.util.ArrayList<java.lang.String> values,
                                       java.lang.String contentType,
                                       java.lang.String charEncoding,
                                       long contentLength)
Starts the caching after the headers have been sent.

Specified by:
startCaching in class AbstractCacheFilterChain
Parameters:
req - the servlet request
req - the servlet response
keys - the saved header keys
values - the saved header values
contentType - the response content type
charEncoding - the response character encoding
Returns:
the inode to store the cache value or null if uncacheable.

finishCaching

public void finishCaching(AbstractCacheEntry requestEntry)
Update the headers when the caching has finished.

Specified by:
finishCaching in class AbstractCacheFilterChain
Parameters:
okay - if true, the cache if valid

killCaching

public void killCaching(AbstractCacheEntry loadingEntry)
Update the headers when the caching has finished.

Specified by:
killCaching in class AbstractCacheFilterChain
Parameters:
okay - if true, the cache if valid

removeEvent

public void removeEvent()
Callback when the item has been removed from the cache, usually because of an LRU event.

Specified by:
removeEvent in interface CacheListener

toString

public java.lang.String toString()
Overrides:
toString in class AbstractFilterChain