Polishing

This commit is contained in:
Juergen Hoeller 2015-09-24 21:36:42 +02:00
parent 11b4e3be2c
commit 75f473927f
2 changed files with 26 additions and 29 deletions

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * a {@code PropertySourcesPlaceholderConfigurer}. This happens automatically when using
* {@code <context:property-placeholder>} in XML, but must be explicitly registered using * {@code <context:property-placeholder>} in XML, but must be explicitly registered using
* a {@code static} {@code @Bean} method when using {@code @Configuration} classes. See * a {@code static} {@code @Bean} method when using {@code @Configuration} classes. See
* the "Working with externalized values" section of @{@link Configuration} Javadoc and * the "Working with externalized values" section of @{@link Configuration}'s javadoc and
* "a note on BeanFactoryPostProcessor-returning @Bean methods" of @{@link Bean} Javadoc * "a note on BeanFactoryPostProcessor-returning @Bean methods" of @{@link Bean}'s javadoc
* for details and examples. * for details and examples.
* *
* <h3>Resolving ${...} placeholders within {@code @PropertySource} resource locations</h3> * <h3>Resolving ${...} placeholders within {@code @PropertySource} resource locations</h3>
@ -126,11 +126,11 @@ import java.lang.annotation.Target;
* <p>In certain situations, it may not be possible or practical to tightly control * <p>In certain situations, it may not be possible or practical to tightly control
* property source ordering when using {@code @ProperySource} annotations. For example, * property source ordering when using {@code @ProperySource} annotations. For example,
* if the {@code @Configuration} classes above were registered via component-scanning, * 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. * it is recommended that the user fall back to using the programmatic PropertySource API.
* See {@link org.springframework.core.env.ConfigurableEnvironment ConfigurableEnvironment} * See {@link org.springframework.core.env.ConfigurableEnvironment ConfigurableEnvironment}
* and {@link org.springframework.core.env.MutablePropertySources MutablePropertySources} * and {@link org.springframework.core.env.MutablePropertySources MutablePropertySources}
* Javadoc for details. * javadocs for details.
* *
* @author Chris Beams * @author Chris Beams
* @author Phillip Webb * @author Phillip Webb
@ -160,11 +160,11 @@ public @interface PropertySource {
* Indicate the resource location(s) of the properties file to be loaded. * Indicate the resource location(s) of the properties file to be loaded.
* For example, {@code "classpath:/com/myco/app.properties"} or * For example, {@code "classpath:/com/myco/app.properties"} or
* {@code "file:/path/to/file"}. * {@code "file:/path/to/file"}.
* <p>Resource location wildcards (e.g. *&#42;/*.properties) are not permitted; each * <p>Resource location wildcards (e.g. *&#42;/*.properties) are not permitted;
* location must evaluate to exactly one {@code .properties} resource. * each location must evaluate to exactly one {@code .properties} resource.
* <p>${...} placeholders will be resolved against any/all property sources already * <p>${...} placeholders will be resolved against any/all property sources already
* registered with the {@code Environment}. See {@linkplain PropertySource above} for * registered with the {@code Environment}. See {@linkplain PropertySource above}
* examples. * for examples.
* <p>Each location will be added to the enclosing {@code Environment} as its own * <p>Each location will be added to the enclosing {@code Environment} as its own
* property source, and in the order declared. * property source, and in the order declared.
*/ */

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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; import org.springframework.util.StringValueResolver;
/** /**
* Specialization of {@link org.springframework.beans.factory.config.PlaceholderConfigurerSupport * Specialization of {@link PlaceholderConfigurerSupport} that resolves ${...} placeholders
* PlaceholderConfigurerSupport} that resolves ${...} placeholders within bean definition * within bean definition property values and {@code @Value} annotations against the current
* property values and {@code @Value} annotations against the current Spring {@link * Spring {@link Environment} and its set of {@link PropertySources}.
* Environment} and its set of {@link PropertySources}.
* *
* <p>This class is designed as a general replacement for {@code * <p>This class is designed as a general replacement for {@code PropertyPlaceholderConfigurer}
* PropertyPlaceholderConfigurer} in Spring 3.1 applications. It is used by default to * in Spring 3.1 applications. It is used by default to support the {@code property-placeholder}
* support the {@code property-placeholder} element in working against the * element in working against the spring-context-3.1 XSD, whereas spring-context versions
* spring-context-3.1 XSD, whereas spring-context versions &lt;= 3.0 default to * &lt;= 3.0 default to {@code PropertyPlaceholderConfigurer} to ensure backward compatibility.
* {@code PropertyPlaceholderConfigurer} to ensure backward compatibility. See * See the spring-context XSD documentation for complete details.
* spring-context XSD documentation for complete details.
* *
* <p>Any local properties (e.g. those added via {@link #setProperties}, * <p>Any local properties (e.g. those added via {@link #setProperties}, {@link #setLocations}
* {@link #setLocations} et al.) are added as a {@code PropertySource}. Search precedence * et al.) are added as a {@code PropertySource}. Search precedence of local properties is
* of local properties is based on the value of the {@link #setLocalOverride localOverride} * based on the value of the {@link #setLocalOverride localOverride} property, which is by
* property, which is by default {@code false} meaning that local properties are to be * default {@code false} meaning that local properties are to be searched last, after all
* searched last, after all environment property sources. * environment property sources.
* *
* <p>See {@link org.springframework.core.env.ConfigurableEnvironment ConfigurableEnvironment} * <p>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 * @author Chris Beams
* @since 3.1 * @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.PlaceholderConfigurerSupport
* @see org.springframework.beans.factory.config.PropertyPlaceholderConfigurer * @see org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
*/ */
public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerSupport public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerSupport implements EnvironmentAware {
implements EnvironmentAware {
/** /**
* {@value} is the name given to the {@link PropertySource} for the set of * {@value} is the name given to the {@link PropertySource} for the set of
@ -139,7 +136,7 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS
} }
try { try {
PropertySource<?> localPropertySource = PropertySource<?> localPropertySource =
new PropertiesPropertySource(LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME, mergeProperties()); new PropertiesPropertySource(LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME, mergeProperties());
if (this.localOverride) { if (this.localOverride) {
this.propertySources.addFirst(localPropertySource); this.propertySources.addFirst(localPropertySource);
} }