org.chwf.servlet.engine
Class ControllerMapper

java.lang.Object
  |
  +--org.chwf.servlet.engine.ControllerMapper

public class ControllerMapper
extends java.lang.Object

Class that maps a particular controller. It has utility methods to invoke the controller reflexively using request data. The mapper for a particular controller class is a singleton.

Author:
Paul Strack

Constructor Summary
ControllerMapper(java.lang.Class controllerClass)
          Constructor for ControllerMapper.
 
Method Summary
static ControllerMapper getMapper(java.lang.Class controllerClass)
          Retrieve the mapper for the controller (a per-class singleton).
 InvocationContext invoke(javax.servlet.http.HttpServletRequest request, java.lang.String methodName)
          Invoke the given method of the controller for the given request.
static InvocationContext invoke(javax.servlet.ServletRequest request)
          Invoke the controller for the servlet request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ControllerMapper

public ControllerMapper(java.lang.Class controllerClass)
                 throws ControllerException
Constructor for ControllerMapper.
Parameters:
controllerClass - The controller being mapped.
Throws:
ControllerException - If the mapper cannot be initialized.
Method Detail

invoke

public static InvocationContext invoke(javax.servlet.ServletRequest request)
                                throws ControllerException
Invoke the controller for the servlet request. This method is intended to be the primary entry point for controller invocations. It returns the InvocationContext which can be used to determine the view page and whether any errors were generated.
InvocationContext context = ControllerMapper.invoke(request);
Parameters:
request - The request.
Returns:
The controller context.
Throws:
ControllerException - For system errors.

getMapper

public static ControllerMapper getMapper(java.lang.Class controllerClass)
                                  throws ControllerException
Retrieve the mapper for the controller (a per-class singleton).
Parameters:
controllerClass - The controller class.
Returns:
The mapper.
Throws:
ControllerException - If the mapper cannot be initialized.

invoke

public InvocationContext invoke(javax.servlet.http.HttpServletRequest request,
                                java.lang.String methodName)
                         throws ControllerException
Invoke the given method of the controller for the given request. The invoke(ServletRequest request) method delegates to this one.
Parameters:
request - The request.
methodName - The name of the method invoked.
Returns:
The invocation context.
Throws:
ControllerException - For system errors.


Copyright © 2002-2004, Paul Strack. All Rights Reserved.