Browse Source

Merge branch '6.2.x'

pull/34864/head
Sam Brannen 9 months ago
parent
commit
6c4651925e
  1. 12
      spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java
  2. 29
      spring-core/src/main/java/org/springframework/core/env/CompositePropertySource.java
  3. 2
      spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java

12
spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@ -50,7 +50,7 @@ import org.springframework.util.StringValueResolver; @@ -50,7 +50,7 @@ import org.springframework.util.StringValueResolver;
* XSD documentation for complete details.
*
* <p>Any local properties (for example, those added via {@link #setProperties}, {@link #setLocations}
* et al.) are added as a {@code PropertySource}. Search precedence of local properties is
* et al.) are added as a single {@link 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.
@ -99,8 +99,9 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS @@ -99,8 +99,9 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS
}
/**
* {@code PropertySources} from the given {@link Environment}
* will be searched when replacing ${...} placeholders.
* {@inheritDoc}
* <p>{@code PropertySources} from the given {@link Environment} will be searched
* when replacing ${...} placeholders.
* @see #setPropertySources
* @see #postProcessBeanFactory
*/
@ -173,6 +174,7 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS @@ -173,6 +174,7 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS
/**
* Create a {@link ConfigurablePropertyResolver} for the specified property sources.
* <p>The default implementation creates a {@link PropertySourcesPropertyResolver}.
* @param propertySources the property sources to use
* @since 6.0.12
*/
@ -185,7 +187,7 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS @@ -185,7 +187,7 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS
* placeholders with values from the given properties.
*/
protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess,
final ConfigurablePropertyResolver propertyResolver) throws BeansException {
ConfigurablePropertyResolver propertyResolver) throws BeansException {
propertyResolver.setPlaceholderPrefix(this.placeholderPrefix);
propertyResolver.setPlaceholderSuffix(this.placeholderSuffix);

29
spring-core/src/main/java/org/springframework/core/env/CompositePropertySource.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@ -40,6 +40,7 @@ import org.springframework.util.StringUtils; @@ -40,6 +40,7 @@ import org.springframework.util.StringUtils;
* @author Chris Beams
* @author Juergen Hoeller
* @author Phillip Webb
* @author Sam Brannen
* @since 3.1.1
*/
public class CompositePropertySource extends EnumerablePropertySource<Object> {
@ -48,13 +49,35 @@ public class CompositePropertySource extends EnumerablePropertySource<Object> { @@ -48,13 +49,35 @@ public class CompositePropertySource extends EnumerablePropertySource<Object> {
/**
* Create a new {@code CompositePropertySource}.
* @param name the name of the property source
* Create a new empty {@code CompositePropertySource} with the given name.
* @param name the name of the composite property source
* @see #CompositePropertySource(String, Iterable)
* @see #addPropertySource(PropertySource)
* @see #addFirstPropertySource(PropertySource)
*/
public CompositePropertySource(String name) {
super(name);
}
/**
* Create a new {@code CompositePropertySource} with the given name and
* property sources supplied as an {@link Iterable} or {@link PropertySources}
* implementation, preserving the original order of the property sources.
* @param name the name of the composite property source
* @param propertySources the initial set of {@link PropertySource} instances
* @since 6.2.7
* @see PropertySources
* @see MutablePropertySources
* @see #addPropertySource(PropertySource)
* @see #addFirstPropertySource(PropertySource)
*/
public CompositePropertySource(String name, Iterable<PropertySource<?>> propertySources) {
this(name);
for (PropertySource<?> propertySource : propertySources) {
this.propertySources.add(propertySource);
}
}
@Override
public @Nullable Object getProperty(String name) {

2
spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java vendored

@ -42,7 +42,7 @@ class PropertySourcesPropertyResolverTests { @@ -42,7 +42,7 @@ class PropertySourcesPropertyResolverTests {
private MutablePropertySources propertySources;
private ConfigurablePropertyResolver propertyResolver;
private PropertySourcesPropertyResolver propertyResolver;
@BeforeEach

Loading…
Cancel
Save