* Returns <code>null</code> if action path is consumed and has been invoked by this controller; otherwise
* the action path string is returned (it might be different than original one, provided in arguments).
* On first invoke, initializes the action configuration before further proceeding.
*/
public String invoke(String actionPath, HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws Exception {
ActionRequest actionRequest = null;
boolean characterEncodingSet = false;
while (actionPath != null) {
if (log.isDebugEnabled()) {
log.debug("Action path: " + actionPath);
}
// build action path
String httpMethod = servletRequest.getMethod().toUpperCase();
actionPath = actionPathRewriter.rewrite(servletRequest, actionPath, httpMethod);
// resolve action configuration
ActionConfig actionConfig = actionsManager.lookup(actionPath, httpMethod);
if (actionConfig == null) {
return actionPath;
}
if (log.isDebugEnabled()) {
log.debug("Invoking action path '" + actionPath + "' using " + actionConfig.actionClass.getSimpleName());
}
// set character encoding
if (!characterEncodingSet && madvocConfig.isApplyCharacterEncoding()) {
String encoding = madvocConfig.getEncoding();
if (encoding != null) {
servletRequest.setCharacterEncoding(encoding);
servletResponse.setCharacterEncoding(encoding);
}
characterEncodingSet = true;
}
// create action object
Object action = createAction(actionConfig.actionClass);
// create action request
ActionRequest previousRequest = actionRequest;
actionRequest = createActionRequest(actionPath, actionConfig, action, servletRequest, servletResponse);
actionRequest.setPreviousActionRequest(previousRequest);
// invoke and render
if (actionConfig.isAsync()) {