From 75f473927fadf5901b923cc03bb918abce33f079 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 24 Sep 2015 21:36:42 +0200 Subject: [PATCH] Polishing --- .../context/annotation/PropertySource.java | 18 ++++----- .../PropertySourcesPlaceholderConfigurer.java | 37 +++++++++---------- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/PropertySource.java b/spring-context/src/main/java/org/springframework/context/annotation/PropertySource.java index 1aea9e9470..115766c687 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/PropertySource.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/PropertySource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 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. @@ -61,8 +61,8 @@ import java.lang.annotation.Target; * a {@code PropertySourcesPlaceholderConfigurer}. This happens automatically when using * {@code } in XML, but must be explicitly registered using * a {@code static} {@code @Bean} method when using {@code @Configuration} classes. See - * the "Working with externalized values" section of @{@link Configuration} Javadoc and - * "a note on BeanFactoryPostProcessor-returning @Bean methods" of @{@link Bean} Javadoc + * the "Working with externalized values" section of @{@link Configuration}'s javadoc and + * "a note on BeanFactoryPostProcessor-returning @Bean methods" of @{@link Bean}'s javadoc * for details and examples. * *

Resolving ${...} placeholders within {@code @PropertySource} resource locations

@@ -126,11 +126,11 @@ import java.lang.annotation.Target; *

In certain situations, it may not be possible or practical to tightly control * property source ordering when using {@code @ProperySource} annotations. For example, * if the {@code @Configuration} classes above were registered via component-scanning, - * the ordering is difficult to predict. In such cases - and if overriding is important - + * the ordering is difficult to predict. In such cases - and if overriding is important - * it is recommended that the user fall back to using the programmatic PropertySource API. * See {@link org.springframework.core.env.ConfigurableEnvironment ConfigurableEnvironment} * and {@link org.springframework.core.env.MutablePropertySources MutablePropertySources} - * Javadoc for details. + * javadocs for details. * * @author Chris Beams * @author Phillip Webb @@ -160,11 +160,11 @@ public @interface PropertySource { * Indicate the resource location(s) of the properties file to be loaded. * For example, {@code "classpath:/com/myco/app.properties"} or * {@code "file:/path/to/file"}. - *

Resource location wildcards (e.g. **/*.properties) are not permitted; each - * location must evaluate to exactly one {@code .properties} resource. + *

Resource location wildcards (e.g. **/*.properties) are not permitted; + * each location must evaluate to exactly one {@code .properties} resource. *

${...} placeholders will be resolved against any/all property sources already - * registered with the {@code Environment}. See {@linkplain PropertySource above} for - * examples. + * registered with the {@code Environment}. See {@linkplain PropertySource above} + * for examples. *

Each location will be added to the enclosing {@code Environment} as its own * property source, and in the order declared. */ diff --git a/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java b/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java index ba0d7d1916..577eb93fda 100644 --- a/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java +++ b/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 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. @@ -35,26 +35,24 @@ import org.springframework.util.Assert; import org.springframework.util.StringValueResolver; /** - * Specialization of {@link org.springframework.beans.factory.config.PlaceholderConfigurerSupport - * PlaceholderConfigurerSupport} that resolves ${...} placeholders within bean definition - * property values and {@code @Value} annotations against the current Spring {@link - * Environment} and its set of {@link PropertySources}. + * Specialization of {@link PlaceholderConfigurerSupport} that resolves ${...} placeholders + * within bean definition property values and {@code @Value} annotations against the current + * Spring {@link Environment} and its set of {@link PropertySources}. * - *

This class is designed as a general replacement for {@code - * PropertyPlaceholderConfigurer} in Spring 3.1 applications. It is used by default to - * support the {@code property-placeholder} element in working against the - * spring-context-3.1 XSD, whereas spring-context versions <= 3.0 default to - * {@code PropertyPlaceholderConfigurer} to ensure backward compatibility. See - * spring-context XSD documentation for complete details. + *

This class is designed as a general replacement for {@code PropertyPlaceholderConfigurer} + * in Spring 3.1 applications. It is used by default to support the {@code property-placeholder} + * element in working against the spring-context-3.1 XSD, whereas spring-context versions + * <= 3.0 default to {@code PropertyPlaceholderConfigurer} to ensure backward compatibility. + * See the spring-context XSD documentation for complete details. * - *

Any local properties (e.g. those added via {@link #setProperties}, - * {@link #setLocations} et al.) are added as a {@code PropertySource}. Search precedence - * of local properties is based on the value of the {@link #setLocalOverride localOverride} - * property, which is by default {@code false} meaning that local properties are to be - * searched last, after all environment property sources. + *

Any local properties (e.g. those added via {@link #setProperties}, {@link #setLocations} + * et al.) are added as a {@code PropertySource}. Search precedence of local properties is + * based on the value of the {@link #setLocalOverride localOverride} property, which is by + * default {@code false} meaning that local properties are to be searched last, after all + * environment property sources. * *

See {@link org.springframework.core.env.ConfigurableEnvironment ConfigurableEnvironment} - * and related Javadoc for details on manipulating environment property sources. + * and related javadocs for details on manipulating environment property sources. * * @author Chris Beams * @since 3.1 @@ -62,8 +60,7 @@ import org.springframework.util.StringValueResolver; * @see org.springframework.beans.factory.config.PlaceholderConfigurerSupport * @see org.springframework.beans.factory.config.PropertyPlaceholderConfigurer */ -public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerSupport - implements EnvironmentAware { +public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerSupport implements EnvironmentAware { /** * {@value} is the name given to the {@link PropertySource} for the set of @@ -139,7 +136,7 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS } try { PropertySource localPropertySource = - new PropertiesPropertySource(LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME, mergeProperties()); + new PropertiesPropertySource(LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME, mergeProperties()); if (this.localOverride) { this.propertySources.addFirst(localPropertySource); }