@@ -138,9 +138,9 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
138
138
139
139
private Long asyncRequestTimeout ;
140
140
141
- private CallableProcessingInterceptor [] callableInterceptors = new CallableProcessingInterceptor [] {} ;
141
+ private CallableProcessingInterceptor [] callableInterceptors = new CallableProcessingInterceptor [0 ] ;
142
142
143
- private DeferredResultProcessingInterceptor [] deferredResultInterceptors = new DeferredResultProcessingInterceptor [] {} ;
143
+ private DeferredResultProcessingInterceptor [] deferredResultInterceptors = new DeferredResultProcessingInterceptor [0 ] ;
144
144
145
145
private boolean ignoreDefaultModelOnRedirect = false ;
146
146
@@ -169,21 +169,18 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
169
169
new LinkedHashMap <ControllerAdviceBean , Set <Method >>();
170
170
171
171
172
- /**
173
- * Default constructor.
174
- */
175
172
public RequestMappingHandlerAdapter () {
176
-
177
173
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter ();
178
- stringHttpMessageConverter .setWriteAcceptCharset (false ); // See SPR-7316
174
+ stringHttpMessageConverter .setWriteAcceptCharset (false ); // see SPR-7316
179
175
180
- this .messageConverters = new ArrayList <HttpMessageConverter <?>>();
176
+ this .messageConverters = new ArrayList <HttpMessageConverter <?>>(4 );
181
177
this .messageConverters .add (new ByteArrayHttpMessageConverter ());
182
178
this .messageConverters .add (stringHttpMessageConverter );
183
179
this .messageConverters .add (new SourceHttpMessageConverter <Source >());
184
180
this .messageConverters .add (new AllEncompassingFormHttpMessageConverter ());
185
181
}
186
182
183
+
187
184
/**
188
185
* Provide resolvers for custom argument types. Custom resolvers are ordered
189
186
* after built-in ones. To override the built-in support for argument
@@ -306,6 +303,14 @@ public List<ModelAndViewResolver> getModelAndViewResolvers() {
306
303
return modelAndViewResolvers ;
307
304
}
308
305
306
+ /**
307
+ * Set the {@link ContentNegotiationManager} to use to determine requested media types.
308
+ * If not set, the default constructor is used.
309
+ */
310
+ public void setContentNegotiationManager (ContentNegotiationManager contentNegotiationManager ) {
311
+ this .contentNegotiationManager = contentNegotiationManager ;
312
+ }
313
+
309
314
/**
310
315
* Provide the converters to use in argument resolvers and return value
311
316
* handlers that support reading and/or writing to the body of the
@@ -315,19 +320,11 @@ public void setMessageConverters(List<HttpMessageConverter<?>> messageConverters
315
320
this .messageConverters = messageConverters ;
316
321
}
317
322
318
- /**
319
- * Set the {@link ContentNegotiationManager} to use to determine requested media types.
320
- * If not set, the default constructor is used.
321
- */
322
- public void setContentNegotiationManager (ContentNegotiationManager contentNegotiationManager ) {
323
- this .contentNegotiationManager = contentNegotiationManager ;
324
- }
325
-
326
323
/**
327
324
* Return the configured message body converters.
328
325
*/
329
326
public List <HttpMessageConverter <?>> getMessageConverters () {
330
- return messageConverters ;
327
+ return this . messageConverters ;
331
328
}
332
329
333
330
/**
@@ -339,10 +336,10 @@ public void setWebBindingInitializer(WebBindingInitializer webBindingInitializer
339
336
}
340
337
341
338
/**
342
- * Return the configured WebBindingInitializer, or {@code null}.
339
+ * Return the configured WebBindingInitializer, or {@code null} if none .
343
340
*/
344
341
public WebBindingInitializer getWebBindingInitializer () {
345
- return webBindingInitializer ;
342
+ return this . webBindingInitializer ;
346
343
}
347
344
348
345
/**
@@ -461,9 +458,8 @@ public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDisc
461
458
}
462
459
463
460
/**
464
- * {@inheritDoc}
465
- * <p>A {@link ConfigurableBeanFactory} is expected for resolving
466
- * expressions in method argument default values.
461
+ * A {@link ConfigurableBeanFactory} is expected for resolving expressions
462
+ * in method argument default values.
467
463
*/
468
464
@ Override
469
465
public void setBeanFactory (BeanFactory beanFactory ) {
@@ -473,12 +469,13 @@ public void setBeanFactory(BeanFactory beanFactory) {
473
469
}
474
470
475
471
/**
476
- * Return the owning factory of this bean instance, or {@code null}.
472
+ * Return the owning factory of this bean instance, or {@code null} if none .
477
473
*/
478
474
protected ConfigurableBeanFactory getBeanFactory () {
479
475
return this .beanFactory ;
480
476
}
481
477
478
+
482
479
@ Override
483
480
public void afterPropertiesSet () {
484
481
if (this .argumentResolvers == null ) {
@@ -638,6 +635,7 @@ private void initControllerAdviceCache() {
638
635
}
639
636
}
640
637
638
+
641
639
/**
642
640
* Always return {@code true} since any method argument and return value
643
641
* type will be processed in some way. A method argument not recognized
@@ -651,19 +649,8 @@ protected boolean supportsInternal(HandlerMethod handlerMethod) {
651
649
return true ;
652
650
}
653
651
654
- /**
655
- * This implementation always returns -1. An {@code @RequestMapping}
656
- * method can calculate the lastModified value, call
657
- * {@link WebRequest#checkNotModified(long)}, and return {@code null}
658
- * if the result of that call is {@code true}.
659
- */
660
- @ Override
661
- protected long getLastModifiedInternal (HttpServletRequest request , HandlerMethod handlerMethod ) {
662
- return -1 ;
663
- }
664
-
665
652
@ Override
666
- protected final ModelAndView handleInternal (HttpServletRequest request ,
653
+ protected ModelAndView handleInternal (HttpServletRequest request ,
667
654
HttpServletResponse response , HandlerMethod handlerMethod ) throws Exception {
668
655
669
656
if (getSessionAttributesHandler (handlerMethod ).hasSessionAttributes ()) {
@@ -690,8 +677,19 @@ protected final ModelAndView handleInternal(HttpServletRequest request,
690
677
}
691
678
692
679
/**
693
- * Return the {@link SessionAttributesHandler} instance for the given
694
- * handler type, never {@code null}.
680
+ * This implementation always returns -1. An {@code @RequestMapping} method can
681
+ * calculate the lastModified value, call {@link WebRequest#checkNotModified(long)},
682
+ * and return {@code null} if the result of that call is {@code true}.
683
+ */
684
+ @ Override
685
+ protected long getLastModifiedInternal (HttpServletRequest request , HandlerMethod handlerMethod ) {
686
+ return -1 ;
687
+ }
688
+
689
+
690
+ /**
691
+ * Return the {@link SessionAttributesHandler} instance for the given handler type
692
+ * (never {@code null}).
695
693
*/
696
694
private SessionAttributesHandler getSessionAttributesHandler (HandlerMethod handlerMethod ) {
697
695
Class <?> handlerType = handlerMethod .getBeanType ();
0 commit comments