Class BaseRequestProcessor
java.lang.Object
org.apache.struts.action.RequestProcessor
org.apache.struts.tiles.TilesRequestProcessor
com.softslate.commerce.customer.core.BaseRequestProcessor
- Direct Known Subclasses:
com.softslate.commerce.customer.core.CheckEERequestProcessor
,InstallerRequestProcessor
public class BaseRequestProcessor
extends org.apache.struts.tiles.TilesRequestProcessor
Subclass of
TilesRequestProcessor
that negotiates each
application request. The subclasses of this class,
CustomerRequestProcessor
and
AdministratorRequestProcessor
, are specified in the
<controller> tags of the struts-config.xml
files, as the
request processors for the customer and adminstrator applications
respectively.- Author:
- David Tobey
-
Field Summary
Modifier and TypeFieldDescriptionstatic String
Path to forward the request to if an error occurs when connecting to the database.static String
Path to forward the request to if the installer is not locked.(package private) static org.apache.commons.logging.Log
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
-
Method Summary
Modifier and TypeMethodDescriptioncom.google.common.eventbus.EventBus
createEventBus
(javax.servlet.http.HttpServletRequest request) com.google.inject.Injector
createGuiceInjector
(javax.servlet.http.HttpServletRequest request) protected void
doForward
(String uri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Overrides the regular forward to use the user's custom layout.getExceptionAsString
(Throwable exception) getRequestParamsDebugMessage
(javax.servlet.http.HttpServletRequest request) Given a request object, converts all the incoming parameters to a string for debugging.void
initializeEventBus
(com.google.common.eventbus.EventBus eventBus, javax.servlet.http.HttpServletRequest request) com.google.inject.Injector
initializeGuice
(javax.servlet.http.HttpServletRequest request) protected void
internalModuleRelativeForward
(String uri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) void
process
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) void
processAuditLogging
(javax.servlet.http.HttpServletRequest request) Create log entries in the application's audit logs, containing all the key information about each request.protected org.apache.struts.action.ActionForward
processException
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception exception, org.apache.struts.action.ActionForm form, org.apache.struts.action.ActionMapping mapping) protected void
processForwardConfig
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.apache.struts.config.ForwardConfig forward) protected boolean
processPreprocess
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Runs initializations and other necessary routines before every request.boolean
sscOnPreRequestBegin
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Performs custom processing at the beginning of each call toprocessPreProcess
.boolean
sscOnPreRequestEnd
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Performs custom processing at the end of each call toprocessPreProcess
.boolean
sscOnPreRequestMiddle
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Performs custom processing in the middle of each call toprocessPreProcess
, directly after thedaoFactory
has been initialized.Methods inherited from class org.apache.struts.tiles.TilesRequestProcessor
getDefinitionsFactory, init, initDefinitionsMapping, internalModuleRelativeInclude, processTilesDefinition, processTilesDefinition
Methods inherited from class org.apache.struts.action.RequestProcessor
destroy, doInclude, getInternal, getServletContext, processActionCreate, processActionForm, processActionPerform, processCachedMessages, processContent, processForward, processInclude, processLocale, processMapping, processMultipart, processNoCache, processPath, processPopulate, processRoles, processValidate
-
Field Details
-
log
static org.apache.commons.logging.Log log -
installerPath
Path to forward the request to if the installer is not locked. This value is/installer/Installer.do
. -
errorPath
Path to forward the request to if an error occurs when connecting to the database. By default this value is/installer/Installer.do
.
-
-
Constructor Details
-
BaseRequestProcessor
public BaseRequestProcessor()
-
-
Method Details
-
processPreprocess
protected boolean processPreprocess(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Runs initializations and other necessary routines before every request.Here are the steps this method takes for each request:
- Calls
sscOnPreRequestBegin()
, which can be overridden by a subclass to provide customizations. - If the
appSettings
orappComponents
objects do not exist in the application scope, initializes them. - If a
BusinessObjectFactory
does not exist in the request scope, initializes a new one. - If a
DAOFactory
does not exist in the application scope, initializes a new one, including initializing Hibernate. - Assigns the application scope's
DAOFactory
to the request'sBusinessObjectFactory
. - If a
Settings
instance does not exist in the application scope, initializes a new one in the application and request scope, and assigns it to the application'sDAOFactory
and the request'sBusinessObjectFactory
. - 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. - Assigns the session scope's
User
to the request'sBusinessObjectFactory
. - If the store's
categoryTree
,builtInCategories
orstatesAndCountries
attributes do not exist in the application scope, initializes them usingProductInitializer
andOrderInitializer
. - Calls
sscOnPreRequestEnd()
, which can be overridden by a subclass to provide customizations.
- Overrides:
processPreprocess
in classorg.apache.struts.action.RequestProcessor
- Parameters:
request
- The servlet request we are processing.response
- The servlet response we are creating.
- Calls
-
createEventBus
public com.google.common.eventbus.EventBus createEventBus(javax.servlet.http.HttpServletRequest request) -
initializeEventBus
public void initializeEventBus(com.google.common.eventbus.EventBus eventBus, javax.servlet.http.HttpServletRequest request) -
initializeGuice
public com.google.inject.Injector initializeGuice(javax.servlet.http.HttpServletRequest request) -
createGuiceInjector
public com.google.inject.Injector createGuiceInjector(javax.servlet.http.HttpServletRequest request) -
sscOnPreRequestBegin
public boolean sscOnPreRequestBegin(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Performs custom processing at the beginning of each call toprocessPreProcess
. It is intended to be overridden by subclasses for customizations. This method should returnfalse
to signalprocessPreProcess
to stop futher processing and returnfalse
itself.- Parameters:
request
- The servlet request we are processing.response
- The servlet response we are creating.- Returns:
true
if the processing was successful,false
if processing in the request should stop.
-
sscOnPreRequestMiddle
public boolean sscOnPreRequestMiddle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Performs custom processing in the middle of each call toprocessPreProcess
, directly after thedaoFactory
has been initialized. It is intended to be overridden by subclasses for customizations. This method should returnfalse
to signalprocessPreProcess
to stop futher processing and returnfalse
itself.- Parameters:
request
- The servlet request we are processing.response
- The servlet response we are creating.- Returns:
true
if the processing was successful,false
if processing in the request should stop.
-
sscOnPreRequestEnd
public boolean sscOnPreRequestEnd(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Performs custom processing at the end of each call toprocessPreProcess
. This method should returnfalse
to signalprocessPreProcess
to returnfalse
itself.- Parameters:
request
- The servlet request we are processing.response
- The servlet response we are creating.- Returns:
true
if the processing was successful,false
if processing should stop.
-
process
public void process(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException - Overrides:
process
in classorg.apache.struts.action.RequestProcessor
- Throws:
IOException
javax.servlet.ServletException
-
processException
protected org.apache.struts.action.ActionForward processException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception exception, org.apache.struts.action.ActionForm form, org.apache.struts.action.ActionMapping mapping) throws IOException, javax.servlet.ServletException - Overrides:
processException
in classorg.apache.struts.action.RequestProcessor
- Throws:
IOException
javax.servlet.ServletException
-
getExceptionAsString
-
processForwardConfig
protected void processForwardConfig(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.apache.struts.config.ForwardConfig forward) throws IOException, javax.servlet.ServletException - Overrides:
processForwardConfig
in classorg.apache.struts.tiles.TilesRequestProcessor
- Throws:
IOException
javax.servlet.ServletException
-
internalModuleRelativeForward
protected void internalModuleRelativeForward(String uri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException - Overrides:
internalModuleRelativeForward
in classorg.apache.struts.tiles.TilesRequestProcessor
- Throws:
IOException
javax.servlet.ServletException
-
doForward
protected void doForward(String uri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException Overrides the regular forward to use the user's custom layout. 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 method affects the forwards to the Tiles definitions for leftLayout, centerLayout, and layout. The same process happens in
AppInsertTag
to handle forwards coming from tiles insert tags.- Overrides:
doForward
in classorg.apache.struts.tiles.TilesRequestProcessor
- Parameters:
uri
- The URI we're forwarding the request to, which may be modified in this method.request
- The servlet request we are processing.response
- The servlet response we are creating.- Throws:
IOException
javax.servlet.ServletException
-
getRequestParamsDebugMessage
Given a request object, converts all the incoming parameters to a string for debugging. The values of certain parameters such as passwords are masked for security.- Parameters:
request
- The current request object.- Returns:
- A String representing the name value pairs of the request parameters.
-
processAuditLogging
public void processAuditLogging(javax.servlet.http.HttpServletRequest request) Create log entries in the application's audit logs, containing all the key information about each request.- Parameters:
request
- The current request object.
-