121
121
* <li>the {@link HandlerMapping} for ViewControllers
122
122
* <li>and the {@link HandlerMapping} for serving resources
123
123
* </ul>
124
- * Note that those beans can be configured by using the {@code path-matching} MVC namespace element.
124
+ * Note that those beans can be configured by using the {@code path-matching}
125
+ * MVC namespace element.
125
126
*
126
127
* <p>Both the {@link RequestMappingHandlerAdapter} and the
127
128
* {@link ExceptionHandlerExceptionResolver} are configured with instances of
131
132
* <li>A {@link DefaultFormattingConversionService}
132
133
* <li>A {@link org.springframework.validation.beanvalidation.LocalValidatorFactoryBean}
133
134
* if a JSR-303 implementation is available on the classpath
134
- * <li>A range of {@link HttpMessageConverter}s depending on what 3rd party
135
+ * <li>A range of {@link HttpMessageConverter}s depending on which third- party
135
136
* libraries are available on the classpath.
136
137
* </ul>
137
138
*
@@ -265,22 +266,23 @@ else if (element.hasAttribute("ignoreDefaultModelOnRedirect")) {
265
266
handlerAdapterDef .getPropertyValues ().add ("deferredResultInterceptors" , deferredResultInterceptors );
266
267
readerContext .getRegistry ().registerBeanDefinition (HANDLER_ADAPTER_BEAN_NAME , handlerAdapterDef );
267
268
268
- String uriCompContribName = MvcUriComponentsBuilder .MVC_URI_COMPONENTS_CONTRIBUTOR_BEAN_NAME ;
269
- RootBeanDefinition uriCompContribDef = new RootBeanDefinition (CompositeUriComponentsContributorFactoryBean .class );
270
- uriCompContribDef .setSource (source );
271
- uriCompContribDef .getPropertyValues ().addPropertyValue ("handlerAdapter" , handlerAdapterDef );
272
- uriCompContribDef .getPropertyValues ().addPropertyValue ("conversionService" , conversionService );
273
- readerContext .getRegistry ().registerBeanDefinition (uriCompContribName , uriCompContribDef );
269
+ RootBeanDefinition uriContributorDef =
270
+ new RootBeanDefinition (CompositeUriComponentsContributorFactoryBean .class );
271
+ uriContributorDef .setSource (source );
272
+ uriContributorDef .getPropertyValues ().addPropertyValue ("handlerAdapter" , handlerAdapterDef );
273
+ uriContributorDef .getPropertyValues ().addPropertyValue ("conversionService" , conversionService );
274
+ String uriContributorName = MvcUriComponentsBuilder .MVC_URI_COMPONENTS_CONTRIBUTOR_BEAN_NAME ;
275
+ readerContext .getRegistry ().registerBeanDefinition (uriContributorName , uriContributorDef );
274
276
275
277
RootBeanDefinition csInterceptorDef = new RootBeanDefinition (ConversionServiceExposingInterceptor .class );
276
278
csInterceptorDef .setSource (source );
277
279
csInterceptorDef .getConstructorArgumentValues ().addIndexedArgumentValue (0 , conversionService );
278
- RootBeanDefinition mappedCsInterceptorDef = new RootBeanDefinition (MappedInterceptor .class );
279
- mappedCsInterceptorDef .setSource (source );
280
- mappedCsInterceptorDef .setRole (BeanDefinition .ROLE_INFRASTRUCTURE );
281
- mappedCsInterceptorDef .getConstructorArgumentValues ().addIndexedArgumentValue (0 , (Object ) null );
282
- mappedCsInterceptorDef .getConstructorArgumentValues ().addIndexedArgumentValue (1 , csInterceptorDef );
283
- String mappedInterceptorName = readerContext .registerWithGeneratedName (mappedCsInterceptorDef );
280
+ RootBeanDefinition mappedInterceptorDef = new RootBeanDefinition (MappedInterceptor .class );
281
+ mappedInterceptorDef .setSource (source );
282
+ mappedInterceptorDef .setRole (BeanDefinition .ROLE_INFRASTRUCTURE );
283
+ mappedInterceptorDef .getConstructorArgumentValues ().addIndexedArgumentValue (0 , (Object ) null );
284
+ mappedInterceptorDef .getConstructorArgumentValues ().addIndexedArgumentValue (1 , csInterceptorDef );
285
+ String mappedInterceptorName = readerContext .registerWithGeneratedName (mappedInterceptorDef );
284
286
285
287
RootBeanDefinition methodExceptionResolver = new RootBeanDefinition (ExceptionHandlerExceptionResolver .class );
286
288
methodExceptionResolver .setSource (source );
@@ -386,7 +388,6 @@ private RuntimeBeanReference getContentNegotiationManager(
386
388
factoryBeanDef .setSource (source );
387
389
factoryBeanDef .setRole (BeanDefinition .ROLE_INFRASTRUCTURE );
388
390
factoryBeanDef .getPropertyValues ().add ("mediaTypes" , getDefaultMediaTypes ());
389
-
390
391
String name = CONTENT_NEGOTIATION_MANAGER_BEAN_NAME ;
391
392
parserContext .getReaderContext ().getRegistry ().registerBeanDefinition (name , factoryBeanDef );
392
393
parserContext .registerComponent (new BeanComponentDefinition (factoryBeanDef , name ));
@@ -401,6 +402,7 @@ private void configurePathMatchingProperties(
401
402
Element pathMatchingElement = DomUtils .getChildElementByTagName (element , "path-matching" );
402
403
if (pathMatchingElement != null ) {
403
404
Object source = parserContext .extractSource (element );
405
+
404
406
if (pathMatchingElement .hasAttribute ("suffix-pattern" )) {
405
407
Boolean useSuffixPatternMatch = Boolean .valueOf (pathMatchingElement .getAttribute ("suffix-pattern" ));
406
408
handlerMappingDef .getPropertyValues ().add ("useSuffixPatternMatch" , useSuffixPatternMatch );
@@ -413,6 +415,7 @@ private void configurePathMatchingProperties(
413
415
Boolean useRegisteredSuffixPatternMatch = Boolean .valueOf (pathMatchingElement .getAttribute ("registered-suffixes-only" ));
414
416
handlerMappingDef .getPropertyValues ().add ("useRegisteredSuffixPatternMatch" , useRegisteredSuffixPatternMatch );
415
417
}
418
+
416
419
RuntimeBeanReference pathHelperRef = null ;
417
420
if (pathMatchingElement .hasAttribute ("path-helper" )) {
418
421
pathHelperRef = new RuntimeBeanReference (pathMatchingElement .getAttribute ("path-helper" ));
@@ -430,18 +433,18 @@ private void configurePathMatchingProperties(
430
433
}
431
434
432
435
private Properties getDefaultMediaTypes () {
433
- Properties props = new Properties ();
436
+ Properties defaultMediaTypes = new Properties ();
434
437
if (romePresent ) {
435
- props .put ("atom" , MediaType .APPLICATION_ATOM_XML_VALUE );
436
- props .put ("rss" , MediaType .APPLICATION_RSS_XML_VALUE );
438
+ defaultMediaTypes .put ("atom" , MediaType .APPLICATION_ATOM_XML_VALUE );
439
+ defaultMediaTypes .put ("rss" , MediaType .APPLICATION_RSS_XML_VALUE );
437
440
}
438
441
if (jaxb2Present || jackson2XmlPresent ) {
439
- props .put ("xml" , MediaType .APPLICATION_XML_VALUE );
442
+ defaultMediaTypes .put ("xml" , MediaType .APPLICATION_XML_VALUE );
440
443
}
441
444
if (jackson2Present || gsonPresent ) {
442
- props .put ("json" , MediaType .APPLICATION_JSON_VALUE );
445
+ defaultMediaTypes .put ("json" , MediaType .APPLICATION_JSON_VALUE );
443
446
}
444
- return props ;
447
+ return defaultMediaTypes ;
445
448
}
446
449
447
450
private RuntimeBeanReference getMessageCodesResolver (Element element ) {
0 commit comments