com.acsinet_solutions.cetia4.controller
Interface ServletRequestHandler

All Known Implementing Classes:
RestRequestHandlerBase

public interface ServletRequestHandler

Request handler for servlet requests. This class helps to provide different implementations for attending web and web service requests and to distinguish between them ( using the handles() method ).

It also allows for implementations dealing with GET methods, and implementations dealing with POST methods.

In future framework implementations, this interface may be important to allow the inclusion of new behaviors and capabilities on the framework ( for example, by allowing a stateful web service implementation, or by supporting view technologies other than JSP ).

Author:
Santiago Arriaga

Method Summary
 ServletRequestContext getRequestContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Get the request handler for the current request.
 RestController getRestController(ServletRequestContext context)
          Get the Rest controller for a given request.
 void handleRequest(ServletRequestContext context, RestController controller)
          Generic method for handling requests, so different response strategies may be implemented.
 boolean handles(javax.servlet.http.HttpServletRequest request)
          Check if the current request handler can handle the given request.
 

Method Detail

handles

boolean handles(javax.servlet.http.HttpServletRequest request)
Check if the current request handler can handle the given request. This typically involves checking the Accept header sent by the client.


getRequestContext

ServletRequestContext getRequestContext(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response)
Get the request handler for the current request. This is done once handles() has returned a positive value for a given request.


getRestController

RestController getRestController(ServletRequestContext context)
Get the Rest controller for a given request. The ServletRequestContext reference must be the one obtained previously using the getRequestContext() method.


handleRequest

void handleRequest(ServletRequestContext context,
                   RestController controller)
                   throws java.io.IOException,
                          javax.servlet.ServletException
Generic method for handling requests, so different response strategies may be implemented. This method is called once appropriate security credentials are checked against the current request context. The provided ServletRequestContext instance provided must be the same that was previously produced using the getRequestContext() method of this same class, and tervletRequestContext reference must be the one obtained previously using the getRequestContext() method.

Throws:
java.io.IOException
javax.servlet.ServletException