com.continuuity.http
Class HttpResourceHandler

java.lang.Object
  extended by com.continuuity.http.HttpResourceHandler
All Implemented Interfaces:
HttpHandler

public final class HttpResourceHandler
extends Object
implements HttpHandler

HttpResourceHandler handles the http request. HttpResourceHandler looks up all Jax-rs annotations in classes and dispatches to appropriate method on receiving requests.


Constructor Summary
HttpResourceHandler(Iterable<? extends HttpHandler> handlers, Iterable<? extends HandlerHook> handlerHooks, URLRewriter urlRewriter)
          Construct HttpResourceHandler.
 
Method Summary
 void destroy(HandlerContext context)
          destroy method will be called before shutdown.
 com.continuuity.http.HttpMethodInfo getDestinationMethod(org.jboss.netty.handler.codec.http.HttpRequest request, HttpResponder responder)
          Call the appropriate handler for handling the httprequest.
 void handle(org.jboss.netty.handler.codec.http.HttpRequest request, HttpResponder responder)
          Call the appropriate handler for handling the httprequest.
 void init(HandlerContext context)
          init method will be called before the netty pipeline is setup.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpResourceHandler

public HttpResourceHandler(Iterable<? extends HttpHandler> handlers,
                           Iterable<? extends HandlerHook> handlerHooks,
                           URLRewriter urlRewriter)
Construct HttpResourceHandler. Reads all annotations from all the handler classes and methods passed in, constructs patternPathRouter which is routable by path to HttpResourceModel as destination of the route.

Parameters:
handlers - Iterable of HttpHandler.
handlerHooks - Iterable of HandlerHook.
urlRewriter - URL re-writer.
Method Detail

handle

public void handle(org.jboss.netty.handler.codec.http.HttpRequest request,
                   HttpResponder responder)
Call the appropriate handler for handling the httprequest. 404 if path is not found. 405 if path is found but httpMethod does not match what's configured.

Parameters:
request - instance of HttpRequest
responder - instance of HttpResponder to handle the request.

getDestinationMethod

public com.continuuity.http.HttpMethodInfo getDestinationMethod(org.jboss.netty.handler.codec.http.HttpRequest request,
                                                                HttpResponder responder)
                                                         throws Exception
Call the appropriate handler for handling the httprequest. 404 if path is not found. 405 if path is found but httpMethod does not match what's configured.

Parameters:
request - instance of HttpRequest
responder - instance of HttpResponder to handle the request.
Returns:
HttpMethodInfo object, null if urlRewriter rewrite returns false, also when method cannot be invoked.
Throws:
Exception

init

public void init(HandlerContext context)
Description copied from interface: HttpHandler
init method will be called before the netty pipeline is setup. Any initialization operation can be performed in this method.

Specified by:
init in interface HttpHandler
Parameters:
context - instance of HandlerContext.

destroy

public void destroy(HandlerContext context)
Description copied from interface: HttpHandler
destroy method will be called before shutdown. Any teardown task can be performed in this method. At this point the server will not accept any more new requests.

Specified by:
destroy in interface HttpHandler
Parameters:
context - instance of HandlerContext.


Copyright 2013 Continuuity, Inc. Licensed under the Apache License, Version 2.0