}
@SuppressWarnings({ "unchecked", "rawtypes" })
public void dispatchAndProcess(List<UrlMappingRule> ruleList) throws Exception {
WebApplicationConfiguration conf = WebApplicationConfiguration.getWebApplicationConfiguration();
WebApplicationContext context = (WebApplicationContext) Context.getCurrentThreadContext();
HttpServletRequest request = context.getRequest();
HttpServletResponse response = context.getResponse();
HttpMethod method = HttpMethod.valueOf(request.getMethod().toUpperCase());
String uri = context.getAccessURI();
if (uri == null) {
uri = URLDecoder.decode(request.getRequestURI(), "UTF-8");
String contextPath = request.getContextPath();
uri = uri.substring(contextPath.length());
context.setAccessURI(uri);
}
String queryString = request.getQueryString();
UrlMappingResult result = conf.getRuleExtractor().findMappedRule(ruleList, method, uri, queryString);
// if not found result, we do not need return 404, instead of user
// defining all match rule
if (result == null) {
logger.warn("There is no matched rule found, we will simply return a 404. You should define your own matching all rule for this case.");
response.setStatus(404);
return;
}
if (logger.isDebugEnabled()) {
logger.debug("apply rule at :" + result.getRule());
}
writePathVarToContext(context, result.getPathVarMap());
UrlMappingRule rule = result.getRule();
context.setData(KEY_CURRENT_RULE, rule);
writePathVarToContext(context, rule.getExtraVarMap());
restoreFlashScopeData(context, request);
List<ContentProvider> requestResult = handleRequest(rule);
for (ContentProvider cp : requestResult) {