Arch4J 1.1

org.arch4j.webpresentation
Class CommandDrivenFrontController

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--org.arch4j.webpresentation.FrontControllerServlet
                    |
                    +--org.arch4j.webpresentation.CommandDrivenFrontController
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class CommandDrivenFrontController
extends FrontControllerServlet

This class implements the FrontController pattern using the Command pattern to implement the request processing.

Version:
$Revision: 1.1 $
Author:
$Author: rgreinke $
See Also:
Serialized Form

Constructor Summary
CommandDrivenFrontController()
           
 
Method Summary
protected  FrontCommand getCommand(javax.servlet.http.HttpServletRequest request)
           
protected  Class getCommandClass(javax.servlet.http.HttpServletRequest request)
          Returns the class name of a FrontCommand to be used to handle the request.
protected  String getCommandPackageName()
          Returns the package name containing the FrontCommand classes.
protected  void handleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handles requests for both HTTP GET and POST methods.
 void init()
          Initialize the servlet.
 
Methods inherited from class org.arch4j.webpresentation.FrontControllerServlet
doGet, doPost, forward
 
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, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandDrivenFrontController

public CommandDrivenFrontController()
Method Detail

getCommandPackageName

protected String getCommandPackageName()
Returns the package name containing the FrontCommand classes.

Returns:
The package name containing the FrontCommand classes.

init

public void init()
          throws javax.servlet.ServletException
Initialize the servlet. Look for an init parameter named commandPackageName, which specifies in which package the receiver should look when looking up FrontCommand classes. Defaults to an empty string, signifying the default package.

Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException - If an exception occurs that interrupts the servlet's normal operation.

handleRequest

protected void handleRequest(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response)
                      throws javax.servlet.ServletException,
                             IOException
Handles requests for both HTTP GET and POST methods.

Specified by:
handleRequest in class FrontControllerServlet
Parameters:
request - An HttpServletRequest object that contains the request the client has made of the servlet.
response - An HttpServletResponse object that contains the response the servlet sends to the client.
Throws:
javax.servlet.ServletException - If the request could not be handled.
IOException - If an input or output error is detected when the servlet handles the request.

getCommand

protected FrontCommand getCommand(javax.servlet.http.HttpServletRequest request)

getCommandClass

protected Class getCommandClass(javax.servlet.http.HttpServletRequest request)
Returns the class name of a FrontCommand to be used to handle the request. The class name is generated by concatenating the command package name (set during init()) with the value of the request parameter command, and then adding Command to the end. For example, if the command package name were com.mywebsite.commands, and the request parameter was command=FindCustomer, then the resulting class would be com.mywebsite.commands.FindCustomerCommand.

If the class cannot be found, UnknownFrontCommand is returned.

Parameters:
request - An HttpServletRequest object that contains the request the client has made of the servlet.
Returns:
A subclass of FrontCommand, a Class object.

Arch4J 1.1

Copyright © 2000-2004 SpiderLogic, a service of Wipfli Ullrich Bertelson LLP.