com.softslate.commerce.customer.core
Class BaseRequestProcessor

java.lang.Object
  extended byorg.apache.struts.action.RequestProcessor
      extended byorg.apache.struts.tiles.TilesRequestProcessor
          extended bycom.softslate.commerce.customer.core.BaseRequestProcessor
Direct Known Subclasses:
CheckRequestProcessor, InstallerRequestProcessor

public class BaseRequestProcessor
extends org.apache.struts.tiles.TilesRequestProcessor

Subclass of TilesRequestProcessor that negotiates each application request.

Author:
David Tobey

Field Summary
static java.lang.String errorPath
          Path to forward the request to if an error occurs when connecting to the database.
static java.lang.String installerSettingsLocation
          The location on the classpath of the properties file that the installer uses to configure the application.
(package private) static org.apache.commons.logging.Log log
           
static java.lang.String systemLayoutDirectory
          The name of the directory under the "WEB-INF/layouts" directory in the application distribution where the system's default jsp templates reside.
 
Fields inherited from class org.apache.struts.tiles.TilesRequestProcessor
definitionsFactory
 
Fields inherited from class org.apache.struts.action.RequestProcessor
actions, INCLUDE_PATH_INFO, INCLUDE_SERVLET_PATH, moduleConfig, servlet
 
Constructor Summary
BaseRequestProcessor()
           
 
Method Summary
protected  java.lang.String alterURI(java.lang.String uri, java.lang.String layout)
          Replaces strings matching the system layout directory with the user's custom layout directory.
protected  void doForward(java.lang.String uri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Override the regular forward to use the user's custom layout, if any.
 java.lang.String getExceptionAsString(java.lang.Throwable exception)
          Recursively loops through a given exception and its causes, and returns a string containing all of the chained exceptions' stack traces.
 boolean npcOnPreRequestBegin(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Performs custom processing at the beginning of each call to processPreProcess.
 boolean npcOnPreRequestEnd(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Performs custom processing at the end of each call to processPreProcess.
protected  org.apache.struts.action.ActionForward processException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Exception exception, org.apache.struts.action.ActionForm form, org.apache.struts.action.ActionMapping mapping)
          Overrides the default processException method to ensure all handled exceptions are logged in the application log file.
protected  boolean processPreprocess(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Runs initializations and other necessary routines before every request into the system.
 
Methods inherited from class org.apache.struts.tiles.TilesRequestProcessor
getDefinitionsFactory, init, initDefinitionsMapping, internalModuleRelativeForward, internalModuleRelativeInclude, processForwardConfig, processTilesDefinition
 
Methods inherited from class org.apache.struts.action.RequestProcessor
destroy, doInclude, getInternal, getServletContext, log, log, process, processActionCreate, processActionForm, processActionPerform, processCachedMessages, processContent, processForward, processInclude, processLocale, processMapping, processMultipart, processNoCache, processPath, processPopulate, processRoles, processValidate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

static org.apache.commons.logging.Log log

installerSettingsLocation

public static final java.lang.String installerSettingsLocation
The location on the classpath of the properties file that the installer uses to configure the application. By default this value is appSettings.properties, meaning the installer will look for a file named appSettings.properties under the classes directory of the application.

See Also:
Constant Field Values

errorPath

public static final java.lang.String errorPath
Path to forward the request to if an error occurs when connecting to the database. By default this value is /installer/Error.do.

See Also:
Constant Field Values

systemLayoutDirectory

public static final java.lang.String systemLayoutDirectory
The name of the directory under the "WEB-INF/layouts" directory in the application distribution where the system's default jsp templates reside.

See Also:
Constant Field Values
Constructor Detail

BaseRequestProcessor

public BaseRequestProcessor()
Method Detail

processPreprocess

protected boolean processPreprocess(javax.servlet.http.HttpServletRequest request,
                                    javax.servlet.http.HttpServletResponse response)
Runs initializations and other necessary routines before every request into the system.

Here are the steps this method takes for each request:

  1. Calls npcOnPreRequestBegin(), which can be overridden by a subclass to provide customizations.
  2. If a BusinessObjectFactory does not exist in the request scope, initializes a new one.
  3. If a DAOFactory does not exist in the application scope, initializes a new one, including creating a connection pool or utilizing a JNDI connection pool.
  4. Assigns the application scope's DAOFactory to the request's BusinessObjectFactory.
  5. If a SettingsBean does not exist in the request scope, initializes a new one.
  6. If a SettingsBean does not exist in the application scope, initializes a new one in the application and request scope, and assigns it to the application's DAOFactory and the request's BusinessObjectFactory.
  7. If a User does not exist in the session scope, or if the user's order has just been placed or has been corrupted somehow, initializes a new one in the session scope.
  8. Assigns the session scope's User to the request's BusinessObjectFactory.
  9. If the store's categoryTree, builtInCategories or statesAndCountries attributes do not exist in the application scope, initializes them

Parameters:
request - The servlet request we are processing.
response - The servlet response we are creating.

npcOnPreRequestBegin

public boolean npcOnPreRequestBegin(javax.servlet.http.HttpServletRequest request,
                                    javax.servlet.http.HttpServletResponse response)
Performs custom processing at the beginning of each call to processPreProcess. It is intended to be overridden by subclasses for customizations. This method should return false to signal processPreProcess to stop futher processing and return false itself.

Returns:
true if the processing was successful, false if processing in the request should stop.

npcOnPreRequestEnd

public boolean npcOnPreRequestEnd(javax.servlet.http.HttpServletRequest request,
                                  javax.servlet.http.HttpServletResponse response)
Performs custom processing at the end of each call to processPreProcess. It is intended to be overridden by subclasses for customizations. This method should return false to signal processPreProcess to return false itself.

Returns:
true if the processing was successful, false if processing should stop.

processException

protected org.apache.struts.action.ActionForward processException(javax.servlet.http.HttpServletRequest request,
                                                                  javax.servlet.http.HttpServletResponse response,
                                                                  java.lang.Exception exception,
                                                                  org.apache.struts.action.ActionForm form,
                                                                  org.apache.struts.action.ActionMapping mapping)
                                                           throws java.io.IOException,
                                                                  javax.servlet.ServletException
Overrides the default processException method to ensure all handled exceptions are logged in the application log file. There should be no unhandled exceptions originating in a Struts action, unless the struts-config.xml file is changed to eliminate the global exception configuration for java.lang.Exception. (It is also possible for an exception to be thrown to the servlet container in this method, if one happens in the course of the exception handling itself.)

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

getExceptionAsString

public java.lang.String getExceptionAsString(java.lang.Throwable exception)
Recursively loops through a given exception and its causes, and returns a string containing all of the chained exceptions' stack traces. Used for logging exceptions.


doForward

protected void doForward(java.lang.String uri,
                         javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response)
                  throws java.io.IOException,
                         javax.servlet.ServletException
Override the regular forward to use the user's custom layout, if any. Replaces pages matching the system layout directory with the user's custom layout directory. If the resulting page doesn't map to an existing file, uses the original instead.

This same process happens in AppInsertTag to handle forwards coming from tiles insert tags.

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

alterURI

protected java.lang.String alterURI(java.lang.String uri,
                                    java.lang.String layout)
Replaces strings matching the system layout directory with the user's custom layout directory. If the resulting path doesn't map to an existing file, returns the original string.



Copyright © SoftSlate, Inc. 2003–2005