Class AbstractRequestHandler

java.lang.Object
com.yahoo.jdisc.AbstractResource
com.yahoo.jdisc.handler.AbstractRequestHandler
All Implemented Interfaces:
RequestHandler, SharedResource
Direct Known Subclasses:
AbstractClientProvider, ThreadedRequestHandler

public abstract class AbstractRequestHandler extends AbstractResource implements RequestHandler

This class provides an abstract RequestHandler implementation with reasonable defaults for everything but RequestHandler.handleRequest(Request, ResponseHandler).

A very simple hello world handler could be implemented like this:

 class HelloWorldHandler extends AbstractRequestHandler {

     @Override
     public ContentChannel handleRequest(Request request, ResponseHandler handler) {
         ContentWriter writer = ResponseDispatch.newInstance(Response.Status.OK).connectWriter(handler);
         try {
             writer.write("Hello World!");
         } finally {
             writer.close();
         }
         return null;
     }
 }
 
Author:
Simon Thoresen Hult