org.qtunes.web
Class CachingWebHandler

java.lang.Object
  extended by org.qtunes.web.CachingWebHandler
All Implemented Interfaces:
WebHandler

public class CachingWebHandler
extends java.lang.Object
implements WebHandler

A wrapping WebHandler that will optionally cache and compress the response from it's handler.


Field Summary
 
Fields inherited from interface org.qtunes.web.WebHandler
DATEFORMAT
 
Constructor Summary
CachingWebHandler(WebHandler handler)
          Create a Caching WebHandler that will wrap the specified handler
 
Method Summary
 void handle(WebConnection con)
           
protected  boolean isCompressable(WebConnection con)
          Return true if the response to the specified WebConnection should compress content of type "application/json" or "text/*".
protected  boolean isModifiedSince(java.net.URI uri, java.util.Date date)
          Return true if the request has been modified since the specified Date and a 304 can be returned.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingWebHandler

public CachingWebHandler(WebHandler handler)
Create a Caching WebHandler that will wrap the specified handler

Method Detail

handle

public void handle(WebConnection con)
            throws java.io.IOException
Specified by:
handle in interface WebHandler
Throws:
java.io.IOException

isModifiedSince

protected boolean isModifiedSince(java.net.URI uri,
                                  java.util.Date date)
Return true if the request has been modified since the specified Date and a 304 can be returned. By default this method returns "true" - subclasses should override this method.

Parameters:
uri - the requested URI
date - the Date of the last copy of this URI on the client
Returns:
true if the resource for this URI has been modified

isCompressable

protected boolean isCompressable(WebConnection con)
Return true if the response to the specified WebConnection should compress content of type "application/json" or "text/*". By default this method returns true. Other MIME-types are never compressed.