AnnotationMethodHandlerAdapter.java 文件源码

java
阅读 23 收藏 0 点赞 0 评论 0

项目:class-guard 作者:
@SuppressWarnings("unchecked")
private ModelAndView invokeHandlerMethod(
        PortletRequest request, PortletResponse response, Object handler, ExtendedModelMap implicitModel)
        throws Exception {

    PortletWebRequest webRequest = new PortletWebRequest(request, response);
    PortletHandlerMethodResolver methodResolver = getMethodResolver(handler);
    Method handlerMethod = methodResolver.resolveHandlerMethod(request);
    PortletHandlerMethodInvoker methodInvoker = new PortletHandlerMethodInvoker(methodResolver);

    Object result = methodInvoker.invokeHandlerMethod(handlerMethod, handler, webRequest, implicitModel);
    ModelAndView mav = methodInvoker.getModelAndView(handlerMethod, handler.getClass(), result, implicitModel,
            webRequest);
    methodInvoker.updateModelAttributes(
            handler, (mav != null ? mav.getModel() : null), implicitModel, webRequest);

    // Expose implicit model for subsequent render phase.
    if (response instanceof StateAwareResponse && !implicitModel.isEmpty()) {
        StateAwareResponse stateResponse = (StateAwareResponse) response;
        Map<?, ?> modelToStore = implicitModel;
        try {
            stateResponse.setRenderParameter(IMPLICIT_MODEL_RENDER_PARAMETER, Boolean.TRUE.toString());
            if (response instanceof EventResponse) {
                // Update the existing model, if any, when responding to an event -
                // whereas we're replacing the model in case of an action response.
                Map existingModel = (Map) request.getPortletSession().getAttribute(IMPLICIT_MODEL_SESSION_ATTRIBUTE);
                if (existingModel != null) {
                    existingModel.putAll(implicitModel);
                    modelToStore = existingModel;
                }
            }
            request.getPortletSession().setAttribute(IMPLICIT_MODEL_SESSION_ATTRIBUTE, modelToStore);
        }
        catch (IllegalStateException ex) {
            // Probably sendRedirect called... no need to expose model to render phase.
        }
    }

    return mav;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号