ccs.http
Class ThrowingHandler

java.lang.Object
  extended by org.mortbay.http.handler.AbstractHttpHandler
      extended by ccs.http.AbstractXhtmlHandler
          extended by ccs.http.ThrowingHandler
All Implemented Interfaces:
java.io.Serializable, org.mortbay.http.HttpHandler, org.mortbay.util.LifeCycle

public abstract class ThrowingHandler
extends AbstractXhtmlHandler

A superclass for HttpHandlers which, in conjunction with ExceptionHandler, provides an communal exception-handling framework for Jetty-based HTTP servers. Note, off-topic but this seems the most effective place to put it - both HttpRequest and HttpResponse offer "fields" (header lines in the HTTP request / response, "parameters" (obtained by parsing any query string) and "attributes". This last allows you to add your own data to the request / response as they travel down the handler chain. It is used by the rest of the system in various places; to avoid clashes, make all your names Strings, and prefix them with your package name. This is a good way for your up-chain handlers to talk to their down-chain compadres.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class ccs.http.AbstractXhtmlHandler
AbstractXhtmlHandler.XHMode
 
Field Summary
protected static java.lang.ThreadLocal<HDate> hdate
          An HDate for parsing dates within the HTTP protocol; eg. for cache checking.
 
Fields inherited from class ccs.http.AbstractXhtmlHandler
isEnabled, mrp
 
Constructor Summary
ThrowingHandler(MimeRegProvider mrp)
          Construct a ThrowingHandler.
 
Method Summary
 void handle(java.lang.String subpath, java.lang.String pathParams, org.mortbay.http.HttpRequest ha, org.mortbay.http.HttpResponse hq)
           
protected  void handleGet(java.lang.String subpath, java.lang.String pathParams, org.mortbay.http.HttpRequest ha, org.mortbay.http.HttpResponse hq)
          Handle GET requests.
protected  void handleHead(java.lang.String subpath, java.lang.String pathParams, org.mortbay.http.HttpRequest ha, org.mortbay.http.HttpResponse hq)
          Handle HEAD requests.
protected  void handleOptions(java.lang.String subpath, java.lang.String pathParams, org.mortbay.http.HttpRequest ha, org.mortbay.http.HttpResponse hq)
          Handle OPTIONS requests.
protected  void handlePost(java.lang.String subpath, java.lang.String pathParams, org.mortbay.http.HttpRequest ha, org.mortbay.http.HttpResponse hq)
          Handle POST requests.
protected  void handlePut(java.lang.String subpath, java.lang.String pathParams, org.mortbay.http.HttpRequest ha, org.mortbay.http.HttpResponse hq)
          Handle PUT requests.
 
Methods inherited from class ccs.http.AbstractXhtmlHandler
getDefaultXHMode, isXhtmlUA, makeUncacheable, sendBuffer, sendCDBFile, sendStream, setXHMode
 
Methods inherited from class org.mortbay.http.handler.AbstractHttpHandler
getHttpContext, getName, handleTrace, initialize, isStarted, setName, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

hdate

protected static java.lang.ThreadLocal<HDate> hdate
An HDate for parsing dates within the HTTP protocol; eg. for cache checking.

Constructor Detail

ThrowingHandler

public ThrowingHandler(MimeRegProvider mrp)
Construct a ThrowingHandler.

Parameters:
mrp - provides the MimeRegistry to be used by sendBuffer to determine the correct MIME type of buffers which don't specify their own MIME type. If null, a default provider will be used.
Method Detail

handle

public final void handle(java.lang.String subpath,
                         java.lang.String pathParams,
                         org.mortbay.http.HttpRequest ha,
                         org.mortbay.http.HttpResponse hq)
                  throws org.mortbay.http.HttpException,
                         java.io.IOException
Throws:
org.mortbay.http.HttpException
java.io.IOException

handleHead

protected void handleHead(java.lang.String subpath,
                          java.lang.String pathParams,
                          org.mortbay.http.HttpRequest ha,
                          org.mortbay.http.HttpResponse hq)
                   throws java.lang.Exception
Handle HEAD requests. The default implementation calls handleGet.

Parameters:
subpath - The path, less the appID (context) prefix.
pathParams - Parameters appended to the path. Usually null.
ha - The request.
hq - The response.
Throws:
java.lang.Exception

handleGet

protected void handleGet(java.lang.String subpath,
                         java.lang.String pathParams,
                         org.mortbay.http.HttpRequest ha,
                         org.mortbay.http.HttpResponse hq)
                  throws java.lang.Exception
Handle GET requests. Pretty much all subclasses will need to override this. The default implementation does nothing and leaves the request unhandled.

Parameters:
subpath - The path, less the appID (context) prefix.
pathParams - Parameters appended to the path. Usually null.
ha - The request.
hq - The response.
Throws:
java.lang.Exception

handlePost

protected void handlePost(java.lang.String subpath,
                          java.lang.String pathParams,
                          org.mortbay.http.HttpRequest ha,
                          org.mortbay.http.HttpResponse hq)
                   throws java.lang.Exception
Handle POST requests. Some subclasses will need to override this, many won't. The default implementation does nothing and leaves the request unhandled.

Parameters:
subpath - The path, less the appID (context) prefix.
pathParams - Parameters appended to the path. Usually null.
ha - The request.
hq - The response.
Throws:
java.lang.Exception

handleOptions

protected void handleOptions(java.lang.String subpath,
                             java.lang.String pathParams,
                             org.mortbay.http.HttpRequest ha,
                             org.mortbay.http.HttpResponse hq)
                      throws java.lang.Exception
Handle OPTIONS requests. Hardly anyone will need to override this. This has been minimally tested and may be buggy.

Parameters:
subpath - The path, less the appID (context) prefix.
pathParams - Parameters appended to the path. Usually null.
ha - The request.
hq - The response.
Throws:
java.lang.Exception

handlePut

protected void handlePut(java.lang.String subpath,
                         java.lang.String pathParams,
                         org.mortbay.http.HttpRequest ha,
                         org.mortbay.http.HttpResponse hq)
                  throws java.lang.Exception
Handle PUT requests. Put allows you to write a resource to the server in the same way as GET allows you to read from it; cf. POST which allows you to send data to the server for processing. The URL of a POST points to a processor / script of some kind, which isn't necessarily readable; the URL of a PUT is the place the client wishes to GET the resource from in future. We don't use this much, if at all; systems which wish to provide writable storage tend to implement full WebDAV.

Parameters:
subpath - The path, less the appID (context) prefix.
pathParams - Parameters appended to the path. Usually null.
ha - The request.
hq - The response.
Throws:
java.lang.Exception