net.sourceforge.stripes.controller
Class DispatcherServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by net.sourceforge.stripes.controller.DispatcherServlet
All Implemented Interfaces:
Serializable, Servlet, ServletConfig

public class DispatcherServlet
extends HttpServlet

Servlet that controls how requests to the Stripes framework are processed. Uses an instance of the ActionResolver interface to locate the bean and method used to handle the current request and then delegates processing to the bean.

Author:
Tim Fennell
See Also:
Serialized Form

Constructor Summary
DispatcherServlet()
           
 
Method Summary
protected  ValidationErrors bindValues(ActionBean bean, ActionBeanContext context, boolean validate)
          Invokes the configured property binder in order to populate the bean's properties from the values contained in the request.
protected  void doGet(HttpServletRequest request, HttpServletResponse response)
          Implemented as a simple call to doPost(request, response).
protected  void doPost(HttpServletRequest request, HttpServletResponse response)
          Uses the configured actionResolver to locate the appropriate ActionBean type and method to handle the current request.
protected  ActionBean getActionBeanInstance(Class<ActionBean> clazz, HttpServletRequest request)
          Gets an instance of the specified ActionBean.
protected  Resolution getErrorResolution(HttpServletRequest request)
          Determines the page to send the user to (and how) in case of validation errors.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DispatcherServlet

public DispatcherServlet()
Method Detail

doGet

protected void doGet(HttpServletRequest request,
                     HttpServletResponse response)
              throws ServletException,
                     IOException
Implemented as a simple call to doPost(request, response).

Overrides:
doGet in class HttpServlet
Throws:
ServletException
IOException

doPost

protected void doPost(HttpServletRequest request,
                      HttpServletResponse response)
               throws ServletException
Uses the configured actionResolver to locate the appropriate ActionBean type and method to handle the current request. Instantiates the ActionBean, provides it references to the request and response and then invokes the handler method.

Overrides:
doPost in class HttpServlet
Parameters:
request - the HttpServletRequest handed to the class by the container
response - the HttpServletResponse paired to the request
Throws:
ServletException - thrown when the system fails to process the request in any way

getActionBeanInstance

protected ActionBean getActionBeanInstance(Class<ActionBean> clazz,
                                           HttpServletRequest request)
                                    throws Exception
Gets an instance of the specified ActionBean. In the default case, the ActionBean will be instantiated and returned. If the ActionBean class is marked with a SessionScope annotation, then the bean instance will be looked for in session scope and, if not found, instantiated and put in session scope.

Parameters:
clazz - the ActionBean class being instantiated/looked up
Returns:
an instance of the ActionBean specified
Throws:
Exception - if the ActionBean cannot be instantiated

bindValues

protected ValidationErrors bindValues(ActionBean bean,
                                      ActionBeanContext context,
                                      boolean validate)
                               throws StripesServletException
Invokes the configured property binder in order to populate the bean's properties from the values contained in the request.

Parameters:
bean - the bean to be populated
context - the ActionBeanContext containing the request and other information
Throws:
StripesServletException

getErrorResolution

protected Resolution getErrorResolution(HttpServletRequest request)
                                 throws StripesServletException
Determines the page to send the user to (and how) in case of validation errors.

Throws:
StripesServletException


© Copyright 2005, Stripes Development Team.