{
//
// First wrap the request with an object that contains request-scoped values that our runtime uses. This
// is faster than sticking everything into attributes on the request (then basically reading from a HashMap).
//
PageFlowRequestWrapper requestWrapper = PageFlowRequestWrapper.wrapRequest( request );
request = requestWrapper;
ServletContext servletContext = getServletContext();
String modulePath = PageFlowUtils.getModulePathForRelativeURI( InternalUtils.getDecodedServletPath( request ) );
ModuleConfig registeredApp;
//
// Get the registered Struts module for the request.
//
registeredApp = getModuleConfig( modulePath, request, response );
//
// If we've dynamically registered a module, then we need to override the base process() behavior to select the
// module. Note that we don't want to synchronize the call to process().
//
if ( registeredApp != null )
{
//
// Try to select the appropriate Struts module and delegate to its RequestProcessor.
//
ModuleConfig moduleConfig = InternalUtils.selectModule( modulePath, request, servletContext );
// If this module came from an abstract page flow controller class, send an error.
ControllerConfig cc = moduleConfig.getControllerConfig();
if (cc instanceof PageFlowControllerConfig && ((PageFlowControllerConfig) cc).isAbstract()) {
InternalUtils.sendDevTimeError( "PageFlow_AbstractPageFlow", null, HttpServletResponse.SC_NOT_FOUND,
request, response, servletContext,
new Object[]{ modulePath } );
return;
}
RequestProcessor requestProcessor = getRequestProcessor( moduleConfig );
requestProcessor.process( request, response );
}
else
{
//
// Here, we're checking to see if this was a module that was registered externally by Struts (not by this
// servlet). This is the same as the base process() behavior, but it checks for a missing
// module-configuration.
//
ModuleConfig moduleConfig = null;
if ( InternalUtils.getModuleConfig( RequestUtils.getModuleName( request, servletContext ), servletContext ) != null )
{
String modulePrefix = RequestUtils.getModuleName( request, servletContext );
moduleConfig = InternalUtils.selectModule( modulePrefix, request, servletContext );
}
String servletPath = InternalUtils.getDecodedServletPath( request );
RequestProcessor rp = moduleConfig != null ? getRequestProcessor( moduleConfig ) : null;
if ( rp != null && moduleCanHandlePath( moduleConfig, rp, servletPath ) )
{
rp.process( request, response );
}
else
{
//
// Initialize the ServletContext in the request. Often, we need access to the ServletContext when we only
// have a ServletRequest.
//
InternalUtils.setServletContext( request, getServletContext() );
if ( processUnhandledAction( request, response, servletPath ) ) return;
String originalServletPath = requestWrapper.getOriginalServletPath();
if ( originalServletPath != null )
{
servletPath = originalServletPath;
modulePath = PageFlowUtils.getModulePathForRelativeURI( originalServletPath );
}