au.com.whitesquare.waf.servlet
Class BaseControllerServlet

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended byau.com.whitesquare.waf.servlet.BaseControllerServlet
All Implemented Interfaces:
Serializable, Servlet, ServletConfig

public abstract class BaseControllerServlet
extends HttpServlet


Last Modified $Date: 2006/04/26 11:04:17 $

Version:
$Revision: 1.26 $
Author:
Steve Mactaggart
See Also:
Serialized Form

Constructor Summary
BaseControllerServlet()
           
 
Method Summary
 void destroy()
           
protected  void doGet(HttpServletRequest req, HttpServletResponse resp)
          The doGet is just re-directed to the doPost.
protected  void doPost(HttpServletRequest req, HttpServletResponse resp)
          The doPost does all of the work parsing the parameters, retreiving the command, then dispatching the repsonse.
protected  CommandKeyResolver getCommandKeyResolver()
          Returns the initalised Command Key Resolver.
protected  CommandResolver getCommandResolver()
           
protected abstract  String getLog4jFileName(ServletConfig config)
          This method is used to retreive the log4j config file that will be used to log debug output from this application.
protected  ParameterParser getParameterParser()
           
protected  void getParameters(WAFRequest wafRequest, HttpServletRequest request)
          Gets all parameters send by the client.
 void init(ServletConfig config)
          Description of the Method
protected  void initLog4j(ServletConfig config)
           
protected  Response processCommand(BaseCommand command, WAFRequest params, HttpServletRequest req, HttpServletResponse resp)
           
protected  void resolveCommandKey(WAFRequest wafRequest, HttpServletRequest req)
          Resolves the request entity's key from the request information.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
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

BaseControllerServlet

public BaseControllerServlet()
Method Detail

init

public void init(ServletConfig config)
          throws ServletException
Description of the Method

Parameters:
config - Description of the Parameter
Throws:
ServletException - Description of the Exception

initLog4j

protected final void initLog4j(ServletConfig config)

getLog4jFileName

protected abstract String getLog4jFileName(ServletConfig config)
This method is used to retreive the log4j config file that will be used to log debug output from this application.
The method is supplied the ServletContext, so that the filename can be stored in the web.xml file.
A Standard configuration may look like:
 <context-param>
   <param-name>LOG4J_PATH</param-name>
   <param-value>/WEB-INF/conf/log4j.properties</param-value>
 </context-param>
 
And then an implementation of the method as follows
 String fileName = config.getServletContext().getInitParameter("LOG4J_PATH"); 
 fileName = config.getServletContext().getRealPath(fileName);
 return fileName;
 

Returns:
the name of the log4j properties file that contains the log4j configurations.

doGet

protected final void doGet(HttpServletRequest req,
                           HttpServletResponse resp)
                    throws ServletException,
                           IOException
The doGet is just re-directed to the doPost.

Throws:
ServletException
IOException
See Also:
HttpServlet.doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

doPost

protected final void doPost(HttpServletRequest req,
                            HttpServletResponse resp)
                     throws ServletException,
                            IOException
The doPost does all of the work parsing the parameters, retreiving the command, then dispatching the repsonse.

Throws:
ServletException
IOException
See Also:
HttpServlet.doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

processCommand

protected final Response processCommand(BaseCommand command,
                                        WAFRequest params,
                                        HttpServletRequest req,
                                        HttpServletResponse resp)
Parameters:
command -
params -
req -
resp -
Returns:
the response object that results from processing the command.

getParameters

protected final void getParameters(WAFRequest wafRequest,
                                   HttpServletRequest request)
                            throws ParameterException
Gets all parameters send by the client.

Parameters:
wafRequest -
request -
Throws:
ParameterException

resolveCommandKey

protected final void resolveCommandKey(WAFRequest wafRequest,
                                       HttpServletRequest req)
Resolves the request entity's key from the request information.

Parameters:
wafRequest -
req -

getCommandKeyResolver

protected CommandKeyResolver getCommandKeyResolver()
Returns the initalised Command Key Resolver.

Returns:
the commandKeyResolver to use for this servlet instance.

getParameterParser

protected ParameterParser getParameterParser()

getCommandResolver

protected CommandResolver getCommandResolver()

destroy

public void destroy()
See Also:
Servlet.destroy()


Copyright © 2004 Whitesquare Software. All Rights Reserved.