use of org.apache.struts2.dispatcher.mapper.ActionMapper in project entando-core by entando.
the class Struts2ServletDispatcher method service.
@Override
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
try {
RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
String currentFrameActionPath = request.getParameter(InternalServletTag.REQUEST_PARAM_FRAMEDEST);
Integer currentFrame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME);
Boolean staticAction = (Boolean) reqCtx.getExtraParam(InternalServletTag.EXTRAPAR_STATIC_ACTION);
boolean executeCustomAction = (null == staticAction || !staticAction) && (null == currentFrameActionPath || Integer.parseInt(currentFrameActionPath) == currentFrame.intValue());
prepare.createActionContext(request, response);
prepare.assignDispatcherToThread();
prepare.setEncodingAndLocale(request, response);
request = prepare.wrapRequest(request);
ActionMapper actionMapper = new ExtendedDefaultActionMapper();
Dispatcher dispatcher = prepare.getDispatcher();
String entandoActionName = EntandoActionUtils.extractEntandoActionName(request);
ActionMapping mapping = actionMapper.getMapping(request, dispatcher.getConfigurationManager());
if (mapping != null && null != entandoActionName && executeCustomAction) {
mapping.setName(entandoActionName);
}
if (mapping == null) {
boolean handled = execute.executeStaticResourceRequest(request, response);
if (!handled) {
throw new ServletException("Resource loading not supported, use the StrutsPrepareAndExecuteFilter instead.");
}
} else {
execute.executeAction(request, response, mapping);
}
} finally {
prepare.cleanupRequest(request);
}
}
use of org.apache.struts2.dispatcher.mapper.ActionMapper in project entando-core by entando.
the class PrepareOperations method findActionMapping.
@Override
public ActionMapping findActionMapping(HttpServletRequest request, HttpServletResponse response, boolean forceLookup) {
ActionMapping mapping = (ActionMapping) request.getAttribute(STRUTS_ACTION_MAPPING_KEY);
if (mapping == null || forceLookup) {
try {
Container container = this._dispatcher.getContainer();
ActionMapper mapper = container.getInstance(ActionMapper.class);
String entandoActionName = EntandoActionUtils.extractEntandoActionName(request);
mapping = mapper.getMapping(request, this._dispatcher.getConfigurationManager());
if (null != entandoActionName) {
mapping.setName(entandoActionName);
}
if (mapping != null) {
request.setAttribute(STRUTS_ACTION_MAPPING_KEY, mapping);
}
} catch (Exception ex) {
this._dispatcher.sendError(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex);
}
}
return mapping;
}
use of org.apache.struts2.dispatcher.mapper.ActionMapper in project onebusaway-application-modules by camsys.
the class MultiActionMapper method setActionMappers.
@Inject(MAPPINGS)
public void setActionMappers(String list) {
if (list != null) {
String[] tokens = list.split(",");
for (String token : tokens) {
String[] kvp = token.split("=");
String key = kvp[0];
String name = kvp[1];
ActionMapper mapper = container.getInstance(ActionMapper.class, name);
if (mapper != null) {
_prefixedActionMappers.add(new Prefixed<ActionMapper>(key, mapper));
} else {
throw new IllegalStateException("unknown ActionMapper " + name);
}
}
}
}
Aggregations