109
109
* {@link #setArgumentResolvers} and {@link #setReturnValueHandlers(List)}.
110
110
*
111
111
* @author Rossen Stoyanchev
112
+ * @author Juergen Hoeller
112
113
* @since 3.1
113
114
* @see HandlerMethodArgumentResolver
114
115
* @see HandlerMethodReturnValueHandler
@@ -720,12 +721,12 @@ protected ModelAndView handleInternal(HttpServletRequest request,
720
721
if (session != null ) {
721
722
Object mutex = WebUtils .getSessionMutex (session );
722
723
synchronized (mutex ) {
723
- return invokeHandleMethod (request , response , handlerMethod );
724
+ return invokeHandlerMethod (request , response , handlerMethod );
724
725
}
725
726
}
726
727
}
727
728
728
- return invokeHandleMethod (request , response , handlerMethod );
729
+ return invokeHandlerMethod (request , response , handlerMethod );
729
730
}
730
731
731
732
/**
@@ -761,25 +762,32 @@ private SessionAttributesHandler getSessionAttributesHandler(HandlerMethod handl
761
762
/**
762
763
* Invoke the {@link RequestMapping} handler method preparing a {@link ModelAndView}
763
764
* if view resolution is required.
765
+ * @since 4.2
766
+ * @see #createInvocableHandlerMethod(HandlerMethod)
764
767
*/
765
- private ModelAndView invokeHandleMethod (HttpServletRequest request ,
768
+ protected ModelAndView invokeHandlerMethod (HttpServletRequest request ,
766
769
HttpServletResponse response , HandlerMethod handlerMethod ) throws Exception {
767
770
768
771
ServletWebRequest webRequest = new ServletWebRequest (request , response );
769
772
770
773
WebDataBinderFactory binderFactory = getDataBinderFactory (handlerMethod );
771
774
ModelFactory modelFactory = getModelFactory (handlerMethod , binderFactory );
772
- ServletInvocableHandlerMethod requestMappingMethod = createRequestMappingMethod (handlerMethod , binderFactory );
775
+
776
+ ServletInvocableHandlerMethod invocableMethod = createInvocableHandlerMethod (handlerMethod );
777
+ invocableMethod .setHandlerMethodArgumentResolvers (this .argumentResolvers );
778
+ invocableMethod .setHandlerMethodReturnValueHandlers (this .returnValueHandlers );
779
+ invocableMethod .setDataBinderFactory (binderFactory );
780
+ invocableMethod .setParameterNameDiscoverer (this .parameterNameDiscoverer );
773
781
774
782
ModelAndViewContainer mavContainer = new ModelAndViewContainer ();
775
783
mavContainer .addAllAttributes (RequestContextUtils .getInputFlashMap (request ));
776
- modelFactory .initModel (webRequest , mavContainer , requestMappingMethod );
784
+ modelFactory .initModel (webRequest , mavContainer , invocableMethod );
777
785
mavContainer .setIgnoreDefaultModelOnRedirect (this .ignoreDefaultModelOnRedirect );
778
786
779
787
AsyncWebRequest asyncWebRequest = WebAsyncUtils .createAsyncWebRequest (request , response );
780
788
asyncWebRequest .setTimeout (this .asyncRequestTimeout );
781
789
782
- final WebAsyncManager asyncManager = WebAsyncUtils .getAsyncManager (request );
790
+ WebAsyncManager asyncManager = WebAsyncUtils .getAsyncManager (request );
783
791
asyncManager .setTaskExecutor (this .taskExecutor );
784
792
asyncManager .setAsyncWebRequest (asyncWebRequest );
785
793
asyncManager .registerCallableInterceptors (this .callableInterceptors );
@@ -789,32 +797,28 @@ private ModelAndView invokeHandleMethod(HttpServletRequest request,
789
797
Object result = asyncManager .getConcurrentResult ();
790
798
mavContainer = (ModelAndViewContainer ) asyncManager .getConcurrentResultContext ()[0 ];
791
799
asyncManager .clearConcurrentResult ();
792
-
793
800
if (logger .isDebugEnabled ()) {
794
801
logger .debug ("Found concurrent result value [" + result + "]" );
795
802
}
796
- requestMappingMethod = requestMappingMethod .wrapConcurrentResult (result );
803
+ invocableMethod = invocableMethod .wrapConcurrentResult (result );
797
804
}
798
805
799
- requestMappingMethod .invokeAndHandle (webRequest , mavContainer );
800
-
806
+ invocableMethod .invokeAndHandle (webRequest , mavContainer );
801
807
if (asyncManager .isConcurrentHandlingStarted ()) {
802
808
return null ;
803
809
}
804
810
805
811
return getModelAndView (mavContainer , modelFactory , webRequest );
806
812
}
807
813
808
- private ServletInvocableHandlerMethod createRequestMappingMethod (
809
- HandlerMethod handlerMethod , WebDataBinderFactory binderFactory ) {
810
-
811
- ServletInvocableHandlerMethod requestMethod ;
812
- requestMethod = new ServletInvocableHandlerMethod (handlerMethod );
813
- requestMethod .setHandlerMethodArgumentResolvers (this .argumentResolvers );
814
- requestMethod .setHandlerMethodReturnValueHandlers (this .returnValueHandlers );
815
- requestMethod .setDataBinderFactory (binderFactory );
816
- requestMethod .setParameterNameDiscoverer (this .parameterNameDiscoverer );
817
- return requestMethod ;
814
+ /**
815
+ * Create a {@link ServletInvocableHandlerMethod} from the given {@link HandlerMethod} definition.
816
+ * @param handlerMethod the {@link HandlerMethod} definition
817
+ * @return the corresponding {@link ServletInvocableHandlerMethod} (or custom subclass thereof)
818
+ * @since 4.2
819
+ */
820
+ protected ServletInvocableHandlerMethod createInvocableHandlerMethod (HandlerMethod handlerMethod ) {
821
+ return new ServletInvocableHandlerMethod (handlerMethod );
818
822
}
819
823
820
824
private ModelFactory getModelFactory (HandlerMethod handlerMethod , WebDataBinderFactory binderFactory ) {
0 commit comments