From cc7c90cca567e41958da1e031520b7662a9ec579 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 16 Nov 2017 10:52:56 +0100 Subject: [PATCH] Polishing --- .../web/servlet/config/MvcNamespaceUtils.java | 21 +++++++++---------- .../config/ResourcesBeanDefinitionParser.java | 3 +-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/MvcNamespaceUtils.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/MvcNamespaceUtils.java index d307f5abea..9a18f90f37 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/MvcNamespaceUtils.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/MvcNamespaceUtils.java @@ -160,13 +160,13 @@ public abstract class MvcNamespaceUtils { * Registers a {@link SimpleControllerHandlerAdapter} under a well-known * name unless already registered. */ - private static void registerSimpleControllerHandlerAdapter(ParserContext cxt, @Nullable Object source) { - if (!cxt.getRegistry().containsBeanDefinition(SIMPLE_CONTROLLER_HANDLER_ADAPTER_BEAN_NAME)) { + private static void registerSimpleControllerHandlerAdapter(ParserContext context, @Nullable Object source) { + if (!context.getRegistry().containsBeanDefinition(SIMPLE_CONTROLLER_HANDLER_ADAPTER_BEAN_NAME)) { RootBeanDefinition beanDef = new RootBeanDefinition(SimpleControllerHandlerAdapter.class); beanDef.setSource(source); beanDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); - cxt.getRegistry().registerBeanDefinition(SIMPLE_CONTROLLER_HANDLER_ADAPTER_BEAN_NAME, beanDef); - cxt.registerComponent(new BeanComponentDefinition(beanDef, SIMPLE_CONTROLLER_HANDLER_ADAPTER_BEAN_NAME)); + context.getRegistry().registerBeanDefinition(SIMPLE_CONTROLLER_HANDLER_ADAPTER_BEAN_NAME, beanDef); + context.registerComponent(new BeanComponentDefinition(beanDef, SIMPLE_CONTROLLER_HANDLER_ADAPTER_BEAN_NAME)); } } @@ -215,7 +215,7 @@ public abstract class MvcNamespaceUtils { /** * Find the {@code ContentNegotiationManager} bean created by or registered * with the {@code annotation-driven} element. - * @return a bean definition, bean reference, or {@code null} + * @return a bean definition, bean reference, or {@code null} if none defined */ @Nullable public static Object getContentNegotiationManager(ParserContext context) { @@ -234,12 +234,11 @@ public abstract class MvcNamespaceUtils { /** * Load the {@link Resource}'s for the given locations with the given * {@link ResourceLoader} and add them to the output list. Also for - * {@link org.springframework.core.io.UrlResource URL-based resources} (e.g. - * files, HTTP URLs, etc) this method supports a special prefix to indicate - * the charset associated with the URL so that relative paths appended to it - * can be encoded correctly, e.g. - * {@code [charset=Windows-31J]http://example.org/path}. The charsets, if - * any, are added to the output map. + * {@link org.springframework.core.io.UrlResource URL-based resources} (e.g. files, + * HTTP URLs, etc) this method supports a special prefix to indicate the charset + * associated with the URL so that relative paths appended to it can be encoded + * correctly, e.g. {@code [charset=Windows-31J]http://example.org/path}. + * The charsets, if any, are added to the output map. * @since 4.3.13 */ public static void loadResourceLocations(String[] locations, ResourceLoader resourceLoader, diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java index bf7a02ad4b..eb6eafe7d7 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java @@ -168,8 +168,7 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser { String locationAttr = element.getAttribute("location"); if (!StringUtils.hasText(locationAttr)) { - String message = "The 'location' attribute is required."; - context.getReaderContext().error(message, context.extractSource(element)); + context.getReaderContext().error("The 'location' attribute is required.", context.extractSource(element)); return null; }