Polishing
This commit is contained in:
parent
318d04cd2b
commit
70424a7e3d
|
@ -121,7 +121,8 @@ import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolv
|
||||||
* <li>the {@link HandlerMapping} for ViewControllers
|
* <li>the {@link HandlerMapping} for ViewControllers
|
||||||
* <li>and the {@link HandlerMapping} for serving resources
|
* <li>and the {@link HandlerMapping} for serving resources
|
||||||
* </ul>
|
* </ul>
|
||||||
* Note that those beans can be configured by using the {@code path-matching} MVC namespace element.
|
* Note that those beans can be configured by using the {@code path-matching}
|
||||||
|
* MVC namespace element.
|
||||||
*
|
*
|
||||||
* <p>Both the {@link RequestMappingHandlerAdapter} and the
|
* <p>Both the {@link RequestMappingHandlerAdapter} and the
|
||||||
* {@link ExceptionHandlerExceptionResolver} are configured with instances of
|
* {@link ExceptionHandlerExceptionResolver} are configured with instances of
|
||||||
|
@ -131,7 +132,7 @@ import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolv
|
||||||
* <li>A {@link DefaultFormattingConversionService}
|
* <li>A {@link DefaultFormattingConversionService}
|
||||||
* <li>A {@link org.springframework.validation.beanvalidation.LocalValidatorFactoryBean}
|
* <li>A {@link org.springframework.validation.beanvalidation.LocalValidatorFactoryBean}
|
||||||
* if a JSR-303 implementation is available on the classpath
|
* if a JSR-303 implementation is available on the classpath
|
||||||
* <li>A range of {@link HttpMessageConverter}s depending on what 3rd party
|
* <li>A range of {@link HttpMessageConverter}s depending on which third-party
|
||||||
* libraries are available on the classpath.
|
* libraries are available on the classpath.
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
|
@ -265,22 +266,23 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
handlerAdapterDef.getPropertyValues().add("deferredResultInterceptors", deferredResultInterceptors);
|
handlerAdapterDef.getPropertyValues().add("deferredResultInterceptors", deferredResultInterceptors);
|
||||||
readerContext.getRegistry().registerBeanDefinition(HANDLER_ADAPTER_BEAN_NAME , handlerAdapterDef);
|
readerContext.getRegistry().registerBeanDefinition(HANDLER_ADAPTER_BEAN_NAME , handlerAdapterDef);
|
||||||
|
|
||||||
String uriCompContribName = MvcUriComponentsBuilder.MVC_URI_COMPONENTS_CONTRIBUTOR_BEAN_NAME;
|
RootBeanDefinition uriContributorDef =
|
||||||
RootBeanDefinition uriCompContribDef = new RootBeanDefinition(CompositeUriComponentsContributorFactoryBean.class);
|
new RootBeanDefinition(CompositeUriComponentsContributorFactoryBean.class);
|
||||||
uriCompContribDef.setSource(source);
|
uriContributorDef.setSource(source);
|
||||||
uriCompContribDef.getPropertyValues().addPropertyValue("handlerAdapter", handlerAdapterDef);
|
uriContributorDef.getPropertyValues().addPropertyValue("handlerAdapter", handlerAdapterDef);
|
||||||
uriCompContribDef.getPropertyValues().addPropertyValue("conversionService", conversionService);
|
uriContributorDef.getPropertyValues().addPropertyValue("conversionService", conversionService);
|
||||||
readerContext.getRegistry().registerBeanDefinition(uriCompContribName, uriCompContribDef);
|
String uriContributorName = MvcUriComponentsBuilder.MVC_URI_COMPONENTS_CONTRIBUTOR_BEAN_NAME;
|
||||||
|
readerContext.getRegistry().registerBeanDefinition(uriContributorName, uriContributorDef);
|
||||||
|
|
||||||
RootBeanDefinition csInterceptorDef = new RootBeanDefinition(ConversionServiceExposingInterceptor.class);
|
RootBeanDefinition csInterceptorDef = new RootBeanDefinition(ConversionServiceExposingInterceptor.class);
|
||||||
csInterceptorDef.setSource(source);
|
csInterceptorDef.setSource(source);
|
||||||
csInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, conversionService);
|
csInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, conversionService);
|
||||||
RootBeanDefinition mappedCsInterceptorDef = new RootBeanDefinition(MappedInterceptor.class);
|
RootBeanDefinition mappedInterceptorDef = new RootBeanDefinition(MappedInterceptor.class);
|
||||||
mappedCsInterceptorDef.setSource(source);
|
mappedInterceptorDef.setSource(source);
|
||||||
mappedCsInterceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
mappedInterceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||||
mappedCsInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, (Object) null);
|
mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(0, (Object) null);
|
||||||
mappedCsInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(1, csInterceptorDef);
|
mappedInterceptorDef.getConstructorArgumentValues().addIndexedArgumentValue(1, csInterceptorDef);
|
||||||
String mappedInterceptorName = readerContext.registerWithGeneratedName(mappedCsInterceptorDef);
|
String mappedInterceptorName = readerContext.registerWithGeneratedName(mappedInterceptorDef);
|
||||||
|
|
||||||
RootBeanDefinition methodExceptionResolver = new RootBeanDefinition(ExceptionHandlerExceptionResolver.class);
|
RootBeanDefinition methodExceptionResolver = new RootBeanDefinition(ExceptionHandlerExceptionResolver.class);
|
||||||
methodExceptionResolver.setSource(source);
|
methodExceptionResolver.setSource(source);
|
||||||
|
@ -386,7 +388,6 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
factoryBeanDef.setSource(source);
|
factoryBeanDef.setSource(source);
|
||||||
factoryBeanDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
factoryBeanDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||||
factoryBeanDef.getPropertyValues().add("mediaTypes", getDefaultMediaTypes());
|
factoryBeanDef.getPropertyValues().add("mediaTypes", getDefaultMediaTypes());
|
||||||
|
|
||||||
String name = CONTENT_NEGOTIATION_MANAGER_BEAN_NAME;
|
String name = CONTENT_NEGOTIATION_MANAGER_BEAN_NAME;
|
||||||
parserContext.getReaderContext().getRegistry().registerBeanDefinition(name , factoryBeanDef);
|
parserContext.getReaderContext().getRegistry().registerBeanDefinition(name , factoryBeanDef);
|
||||||
parserContext.registerComponent(new BeanComponentDefinition(factoryBeanDef, name));
|
parserContext.registerComponent(new BeanComponentDefinition(factoryBeanDef, name));
|
||||||
|
@ -401,6 +402,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
Element pathMatchingElement = DomUtils.getChildElementByTagName(element, "path-matching");
|
Element pathMatchingElement = DomUtils.getChildElementByTagName(element, "path-matching");
|
||||||
if (pathMatchingElement != null) {
|
if (pathMatchingElement != null) {
|
||||||
Object source = parserContext.extractSource(element);
|
Object source = parserContext.extractSource(element);
|
||||||
|
|
||||||
if (pathMatchingElement.hasAttribute("suffix-pattern")) {
|
if (pathMatchingElement.hasAttribute("suffix-pattern")) {
|
||||||
Boolean useSuffixPatternMatch = Boolean.valueOf(pathMatchingElement.getAttribute("suffix-pattern"));
|
Boolean useSuffixPatternMatch = Boolean.valueOf(pathMatchingElement.getAttribute("suffix-pattern"));
|
||||||
handlerMappingDef.getPropertyValues().add("useSuffixPatternMatch", useSuffixPatternMatch);
|
handlerMappingDef.getPropertyValues().add("useSuffixPatternMatch", useSuffixPatternMatch);
|
||||||
|
@ -413,6 +415,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
Boolean useRegisteredSuffixPatternMatch = Boolean.valueOf(pathMatchingElement.getAttribute("registered-suffixes-only"));
|
Boolean useRegisteredSuffixPatternMatch = Boolean.valueOf(pathMatchingElement.getAttribute("registered-suffixes-only"));
|
||||||
handlerMappingDef.getPropertyValues().add("useRegisteredSuffixPatternMatch", useRegisteredSuffixPatternMatch);
|
handlerMappingDef.getPropertyValues().add("useRegisteredSuffixPatternMatch", useRegisteredSuffixPatternMatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
RuntimeBeanReference pathHelperRef = null;
|
RuntimeBeanReference pathHelperRef = null;
|
||||||
if (pathMatchingElement.hasAttribute("path-helper")) {
|
if (pathMatchingElement.hasAttribute("path-helper")) {
|
||||||
pathHelperRef = new RuntimeBeanReference(pathMatchingElement.getAttribute("path-helper"));
|
pathHelperRef = new RuntimeBeanReference(pathMatchingElement.getAttribute("path-helper"));
|
||||||
|
@ -430,18 +433,18 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Properties getDefaultMediaTypes() {
|
private Properties getDefaultMediaTypes() {
|
||||||
Properties props = new Properties();
|
Properties defaultMediaTypes = new Properties();
|
||||||
if (romePresent) {
|
if (romePresent) {
|
||||||
props.put("atom", MediaType.APPLICATION_ATOM_XML_VALUE);
|
defaultMediaTypes.put("atom", MediaType.APPLICATION_ATOM_XML_VALUE);
|
||||||
props.put("rss", MediaType.APPLICATION_RSS_XML_VALUE);
|
defaultMediaTypes.put("rss", MediaType.APPLICATION_RSS_XML_VALUE);
|
||||||
}
|
}
|
||||||
if (jaxb2Present || jackson2XmlPresent) {
|
if (jaxb2Present || jackson2XmlPresent) {
|
||||||
props.put("xml", MediaType.APPLICATION_XML_VALUE);
|
defaultMediaTypes.put("xml", MediaType.APPLICATION_XML_VALUE);
|
||||||
}
|
}
|
||||||
if (jackson2Present || gsonPresent) {
|
if (jackson2Present || gsonPresent) {
|
||||||
props.put("json", MediaType.APPLICATION_JSON_VALUE);
|
defaultMediaTypes.put("json", MediaType.APPLICATION_JSON_VALUE);
|
||||||
}
|
}
|
||||||
return props;
|
return defaultMediaTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private RuntimeBeanReference getMessageCodesResolver(Element element) {
|
private RuntimeBeanReference getMessageCodesResolver(Element element) {
|
||||||
|
|
Loading…
Reference in New Issue