From fc361844ec25fadaf21fe8cc28d0179d6b83c801 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 22 Jan 2014 23:57:48 +0100 Subject: [PATCH] Polishing Issue: SPR-11297 --- .../core/env/SystemEnvironmentPropertySource.java | 14 +++++++------- .../AnnotationConfigWebApplicationContext.java | 7 +++---- .../support/StandardServletEnvironment.java | 8 ++++---- .../context/support/XmlWebApplicationContext.java | 4 ++-- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/env/SystemEnvironmentPropertySource.java b/spring-core/src/main/java/org/springframework/core/env/SystemEnvironmentPropertySource.java index 0baba6a8c1..3c4d061739 100644 --- a/spring-core/src/main/java/org/springframework/core/env/SystemEnvironmentPropertySource.java +++ b/spring-core/src/main/java/org/springframework/core/env/SystemEnvironmentPropertySource.java @@ -51,8 +51,8 @@ import org.springframework.util.Assert; *

Enable debug- or trace-level logging for this class (or package) for messages * explaining when these 'property name resolutions' occur. * - *

This property source is included by default in {@link StandardEnvironment} and all - * its subclasses. + *

This property source is included by default in {@link StandardEnvironment} + * and all its subclasses. * * @author Chris Beams * @since 3.1 @@ -76,7 +76,7 @@ public class SystemEnvironmentPropertySource extends MapPropertySource { */ @Override public boolean containsProperty(String name) { - return getProperty(name) != null; + return (getProperty(name) != null); } /** @@ -89,9 +89,8 @@ public class SystemEnvironmentPropertySource extends MapPropertySource { Assert.notNull(name, "property name must not be null"); String actualName = resolvePropertyName(name); if (logger.isDebugEnabled() && !name.equals(actualName)) { - logger.debug(String.format( - "PropertySource [%s] does not contain '%s', but found equivalent '%s'", - this.getName(), name, actualName)); + logger.debug(String.format("PropertySource [%s] does not contain '%s', but found equivalent '%s'", + getName(), name, actualName)); } return super.getProperty(actualName); } @@ -115,7 +114,8 @@ public class SystemEnvironmentPropertySource extends MapPropertySource { if (!name.equals(ucName)) { if (super.containsProperty(ucName)) { return ucName; - } else { + } + else { String usUcName = ucName.replace('.', '_'); if (!ucName.equals(usUcName) && super.containsProperty(usUcName)) { return usUcName; diff --git a/spring-web/src/main/java/org/springframework/web/context/support/AnnotationConfigWebApplicationContext.java b/spring-web/src/main/java/org/springframework/web/context/support/AnnotationConfigWebApplicationContext.java index 5a0837a556..c4c1ec3d34 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/AnnotationConfigWebApplicationContext.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/AnnotationConfigWebApplicationContext.java @@ -186,18 +186,17 @@ public class AnnotationConfigWebApplicationContext extends AbstractRefreshableWe @Override protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) { AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(beanFactory); - reader.setEnvironment(this.getEnvironment()); + reader.setEnvironment(getEnvironment()); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(beanFactory); - scanner.setEnvironment(this.getEnvironment()); + scanner.setEnvironment(getEnvironment()); BeanNameGenerator beanNameGenerator = getBeanNameGenerator(); ScopeMetadataResolver scopeMetadataResolver = getScopeMetadataResolver(); if (beanNameGenerator != null) { reader.setBeanNameGenerator(beanNameGenerator); scanner.setBeanNameGenerator(beanNameGenerator); - beanFactory.registerSingleton( - AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR, beanNameGenerator); + beanFactory.registerSingleton(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR, beanNameGenerator); } if (scopeMetadataResolver != null) { reader.setScopeMetadataResolver(scopeMetadataResolver); diff --git a/spring-web/src/main/java/org/springframework/web/context/support/StandardServletEnvironment.java b/spring-web/src/main/java/org/springframework/web/context/support/StandardServletEnvironment.java index 21a1ce9cf1..e83b373bfe 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/StandardServletEnvironment.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/StandardServletEnvironment.java @@ -67,10 +67,10 @@ public class StandardServletEnvironment extends StandardEnvironment implements C * {@value #JNDI_PROPERTY_SOURCE_NAME}. *

Properties in any of the above will take precedence over system properties and * environment variables contributed by the {@link StandardEnvironment} superclass. - *

The {@code Servlet}-related property sources are added as {@link - * StubPropertySource stubs} at this stage, and will be {@linkplain - * #initPropertySources(ServletContext, ServletConfig) fully initialized} once the actual - * {@link ServletContext} object becomes available. + *

The {@code Servlet}-related property sources are added as + * {@link StubPropertySource stubs} at this stage, and will be + * {@linkplain #initPropertySources(ServletContext, ServletConfig) fully initialized} + * once the actual {@link ServletContext} object becomes available. * @see StandardEnvironment#customizePropertySources * @see org.springframework.core.env.AbstractEnvironment#customizePropertySources * @see ServletConfigPropertySource diff --git a/spring-web/src/main/java/org/springframework/web/context/support/XmlWebApplicationContext.java b/spring-web/src/main/java/org/springframework/web/context/support/XmlWebApplicationContext.java index 84d4b38f3c..faa9475676 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/XmlWebApplicationContext.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/XmlWebApplicationContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,7 +84,7 @@ public class XmlWebApplicationContext extends AbstractRefreshableWebApplicationC // Configure the bean definition reader with this context's // resource loading environment. - beanDefinitionReader.setEnvironment(this.getEnvironment()); + beanDefinitionReader.setEnvironment(getEnvironment()); beanDefinitionReader.setResourceLoader(this); beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this)); -- GitLab