Skip to content

Commit 47c9278

Browse files
committed
renamed AbstractPropertyPlaceholderConfigurer to PlaceholderConfigurerSupport
1 parent 93304b5 commit 47c9278

File tree

3 files changed

+66
-60
lines changed

3 files changed

+66
-60
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
* @see PropertyPlaceholderConfigurer
8686
* @see org.springframework.context.support.PropertySourcesPlaceholderConfigurer
8787
*/
88-
public abstract class AbstractPropertyPlaceholderConfigurer extends PropertyResourceConfigurer
88+
public abstract class PlaceholderConfigurerSupport extends PropertyResourceConfigurer
8989
implements BeanNameAware, BeanFactoryAware {
9090

9191
/** Default placeholder prefix: {@value} */
@@ -97,6 +97,7 @@ public abstract class AbstractPropertyPlaceholderConfigurer extends PropertyReso
9797
/** Default value separator: {@value} */
9898
public static final String DEFAULT_VALUE_SEPARATOR = ":";
9999

100+
100101
/** Defaults to {@value #DEFAULT_PLACEHOLDER_PREFIX} */
101102
protected String placeholderPrefix = DEFAULT_PLACEHOLDER_PREFIX;
102103

@@ -189,8 +190,10 @@ public void setBeanFactory(BeanFactory beanFactory) {
189190
this.beanFactory = beanFactory;
190191
}
191192

193+
192194
protected void doProcessProperties(ConfigurableListableBeanFactory beanFactoryToProcess,
193195
StringValueResolver valueResolver) {
196+
194197
BeanDefinitionVisitor visitor = new BeanDefinitionVisitor(valueResolver);
195198

196199
String[] beanNames = beanFactoryToProcess.getBeanDefinitionNames();

org.springframework.beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@
2020
import java.util.Set;
2121

2222
import org.springframework.beans.BeansException;
23-
import org.springframework.beans.factory.BeanFactoryAware;
24-
import org.springframework.beans.factory.BeanNameAware;
2523
import org.springframework.core.Constants;
2624
import org.springframework.util.PropertyPlaceholderHelper;
2725
import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver;
2826
import org.springframework.util.StringValueResolver;
2927

3028
/**
31-
* {@link AbstractPropertyPlaceholderConfigurer} subclass that resolves ${...} placeholders
29+
* {@link PlaceholderConfigurerSupport} subclass that resolves ${...} placeholders
3230
* against {@link #setLocation local} {@link #setProperties properties} and/or system properties
3331
* and environment variables.
3432
*
@@ -39,31 +37,30 @@
3937
*
4038
* <p>{@link PropertyPlaceholderConfigurer} is still appropriate for use when:
4139
* <ul>
42-
* <li>the {@link org.springframework.context spring-context} module is not available (i.e., one is using
43-
* Spring's {@code BeanFactory} API as opposed to {@code ApplicationContext}).
44-
* <li>existing configuration makes use of the {@link #setSystemPropertiesMode(int) "systemPropertiesMode"} and/or
45-
* {@link #setSystemPropertiesModeName(String) "systemPropertiesModeName"} properties. Users are encouraged to move
46-
* away from using these settings, and rather configure property source search order through the container's
47-
* {@code Environment}; however, exact preservation of functionality may be maintained by continuing to
48-
* use {@code PropertyPlaceholderConfigurer}.
40+
* <li>the {@link org.springframework.context spring-context} module is not available (i.e., one is using
41+
* Spring's {@code BeanFactory} API as opposed to {@code ApplicationContext}).
42+
* <li>existing configuration makes use of the {@link #setSystemPropertiesMode(int) "systemPropertiesMode"} and/or
43+
* {@link #setSystemPropertiesModeName(String) "systemPropertiesModeName"} properties. Users are encouraged to move
44+
* away from using these settings, and rather configure property source search order through the container's
45+
* {@code Environment}; however, exact preservation of functionality may be maintained by continuing to
46+
* use {@code PropertyPlaceholderConfigurer}.
4947
* </ul>
5048
*
5149
* <p>Prior to Spring 3.1, the {@code <context:property-placeholder/>} namespace element
52-
* registered an instance of {@code PropertyPlaceholderConfigurer}. It will still do so if
53-
* using the {@code spring-beans-3.0.xsd} definition of the namespace. That is, you can preserve
50+
* registered an instance of {@code PropertyPlaceholderConfigurer}. It will still do so if
51+
* using the {@code spring-context-3.0.xsd} definition of the namespace. That is, you can preserve
5452
* registration of {@code PropertyPlaceholderConfigurer} through the namespace, even if using Spring 3.1;
5553
* simply do not update your {@code xsi:schemaLocation} and continue using the 3.0 XSD.
5654
*
5755
* @author Juergen Hoeller
5856
* @author Chris Beams
5957
* @since 02.10.2003
6058
* @see #setSystemPropertiesModeName
61-
* @see AbstractPropertyPlaceholderConfigurer
59+
* @see PlaceholderConfigurerSupport
6260
* @see PropertyOverrideConfigurer
6361
* @see org.springframework.context.support.PropertySourcesPlaceholderConfigurer
6462
*/
65-
public class PropertyPlaceholderConfigurer extends AbstractPropertyPlaceholderConfigurer
66-
implements BeanNameAware, BeanFactoryAware {
63+
public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport {
6764

6865
/** Never check system properties. */
6966
public static final int SYSTEM_PROPERTIES_MODE_NEVER = 0;
@@ -140,7 +137,7 @@ public void setSearchSystemEnvironment(boolean searchSystemEnvironment) {
140137
/**
141138
* Resolve the given placeholder using the given properties, performing
142139
* a system properties check according to the given mode.
143-
* <p>Default implementation delegates to <code>resolvePlaceholder
140+
* <p>The default implementation delegates to <code>resolvePlaceholder
144141
* (placeholder, props)</code> before/after the system properties check.
145142
* <p>Subclasses can override this for custom resolution strategies,
146143
* including customized points for the system properties check.
@@ -209,6 +206,7 @@ protected String resolveSystemProperty(String key) {
209206
}
210207
}
211208

209+
212210
/**
213211
* Visit each bean definition in the given bean factory and attempt to replace ${...} property
214212
* placeholders with values from the given properties.
@@ -222,6 +220,25 @@ protected void processProperties(ConfigurableListableBeanFactory beanFactoryToPr
222220
this.doProcessProperties(beanFactoryToProcess, valueResolver);
223221
}
224222

223+
/**
224+
* Parse the given String value for placeholder resolution.
225+
* @param strVal the String value to parse
226+
* @param props the Properties to resolve placeholders against
227+
* @param visitedPlaceholders the placeholders that have already been visited
228+
* during the current resolution attempt (ignored in this version of the code)
229+
* @deprecated as of Spring 3.0, in favor of using {@link #resolvePlaceholder}
230+
* with {@link org.springframework.util.PropertyPlaceholderHelper}.
231+
* Only retained for compatibility with Spring 2.5 extensions.
232+
*/
233+
@Deprecated
234+
protected String parseStringValue(String strVal, Properties props, Set<?> visitedPlaceholders) {
235+
PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper(
236+
placeholderPrefix, placeholderSuffix, valueSeparator, ignoreUnresolvablePlaceholders);
237+
PlaceholderResolver resolver = new PropertyPlaceholderConfigurerResolver(props);
238+
return helper.replacePlaceholders(strVal, resolver);
239+
}
240+
241+
225242
private class PlaceholderResolvingStringValueResolver implements StringValueResolver {
226243

227244
private final PropertyPlaceholderHelper helper;
@@ -240,23 +257,6 @@ public String resolveStringValue(String strVal) throws BeansException {
240257
}
241258
}
242259

243-
/**
244-
* Parse the given String value for placeholder resolution.
245-
* @param strVal the String value to parse
246-
* @param props the Properties to resolve placeholders against
247-
* @param visitedPlaceholders the placeholders that have already been visited
248-
* during the current resolution attempt (ignored in this version of the code)
249-
* @deprecated as of Spring 3.0, in favor of using {@link #resolvePlaceholder}
250-
* with {@link org.springframework.util.PropertyPlaceholderHelper}.
251-
* Only retained for compatibility with Spring 2.5 extensions.
252-
*/
253-
@Deprecated
254-
protected String parseStringValue(String strVal, Properties props, Set<?> visitedPlaceholders) {
255-
PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper(
256-
placeholderPrefix, placeholderSuffix, valueSeparator, ignoreUnresolvablePlaceholders);
257-
PlaceholderResolver resolver = new PropertyPlaceholderConfigurerResolver(props);
258-
return helper.replacePlaceholders(strVal, resolver);
259-
}
260260

261261
private class PropertyPlaceholderConfigurerResolver implements PlaceholderResolver {
262262

org.springframework.context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
package org.springframework.context.support;
1818

1919
import java.io.IOException;
20+
import java.util.Properties;
2021

2122
import org.springframework.beans.BeansException;
2223
import org.springframework.beans.factory.BeanInitializationException;
23-
import org.springframework.beans.factory.config.AbstractPropertyPlaceholderConfigurer;
2424
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
25+
import org.springframework.beans.factory.config.PlaceholderConfigurerSupport;
2526
import org.springframework.context.EnvironmentAware;
2627
import org.springframework.core.env.ConfigurablePropertyResolver;
2728
import org.springframework.core.env.Environment;
@@ -33,17 +34,17 @@
3334
import org.springframework.util.StringValueResolver;
3435

3536
/**
36-
* Specialization of {@link AbstractPropertyPlaceholderConfigurer}
37+
* Specialization of {@link org.springframework.beans.factory.config.PlaceholderConfigurerSupport}
3738
*
3839
* <p>Local properties are added as a property source in any case. Precedence is based
3940
* on the value of the {@link #setLocalOverride localOverride} property.
4041
*
4142
* @author Chris Beams
4243
* @since 3.1
43-
* @see AbstractPropertyPlaceholderConfigurer
44+
* @see org.springframework.beans.factory.config.PlaceholderConfigurerSupport
4445
* @see org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
4546
*/
46-
public class PropertySourcesPlaceholderConfigurer extends AbstractPropertyPlaceholderConfigurer
47+
public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerSupport
4748
implements EnvironmentAware {
4849

4950
/**
@@ -58,21 +59,12 @@ public class PropertySourcesPlaceholderConfigurer extends AbstractPropertyPlaceh
5859
*/
5960
public static final String ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME = "environmentProperties";
6061

62+
6163
private MutablePropertySources propertySources;
6264

6365
private Environment environment;
6466

6567

66-
/**
67-
* {@inheritDoc}
68-
* <p>{@code PropertySources} from this environment will be searched when replacing ${...} placeholders
69-
* @see #setPropertySources
70-
* @see #postProcessBeanFactory
71-
*/
72-
public void setEnvironment(Environment environment) {
73-
this.environment = environment;
74-
}
75-
7668
/**
7769
* Customize the set of {@link PropertySources} to be used by this configurer.
7870
* Setting this property indicates that environment property sources and local
@@ -83,17 +75,28 @@ public void setPropertySources(PropertySources propertySources) {
8375
this.propertySources = new MutablePropertySources(propertySources);
8476
}
8577

78+
/**
79+
* {@inheritDoc}
80+
* <p>{@code PropertySources} from this environment will be searched when replacing ${...} placeholders.
81+
* @see #setPropertySources
82+
* @see #postProcessBeanFactory
83+
*/
84+
public void setEnvironment(Environment environment) {
85+
this.environment = environment;
86+
}
87+
88+
8689
/**
8790
* {@inheritDoc}
8891
* <p>Processing occurs by replacing ${...} placeholders in bean definitions by resolving each
8992
* against this configurer's set of {@link PropertySources}, which includes:
9093
* <ul>
91-
* <li>all {@linkplain Environment#getPropertySources environment property sources}, if an
92-
* {@code Environment} {@linkplain #setEnvironment is present}
93-
* <li>{@linkplain #mergeProperties merged local properties}, if {@linkplain #setLocation any}
94-
* {@linkplain #setLocations have} {@linkplain #setProperties been}
95-
* {@linkplain #setPropertiesArray specified}
96-
* <li>any property sources set by calling {@link #setPropertySources}
94+
* <li>all {@linkplain Environment#getPropertySources environment property sources}, if an
95+
* {@code Environment} {@linkplain #setEnvironment is present}
96+
* <li>{@linkplain #mergeProperties merged local properties}, if {@linkplain #setLocation any}
97+
* {@linkplain #setLocations have} {@linkplain #setProperties been}
98+
* {@linkplain #setPropertiesArray specified}
99+
* <li>any property sources set by calling {@link #setPropertySources}
97100
* </ul>
98101
* <p>If {@link #setPropertySources} is called, <strong>environment and local properties will be
99102
* ignored</strong>. This method is designed to give the user fine-grained control over property
@@ -118,7 +121,8 @@ public String getProperty(String key) {
118121
new PropertiesPropertySource(LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME, this.mergeProperties());
119122
if (this.localOverride) {
120123
this.propertySources.addFirst(localPropertySource);
121-
} else {
124+
}
125+
else {
122126
this.propertySources.addLast(localPropertySource);
123127
}
124128
}
@@ -150,20 +154,19 @@ public String resolveStringValue(String strVal) {
150154
}
151155
};
152156

153-
this.doProcessProperties(beanFactoryToProcess, valueResolver);
157+
doProcessProperties(beanFactoryToProcess, valueResolver);
154158
}
155159

156160
/**
157-
* Implemented for compatibility with {@link AbstractPropertyPlaceholderConfigurer}.
161+
* Implemented for compatibility with {@link org.springframework.beans.factory.config.PlaceholderConfigurerSupport}.
158162
* @deprecated in favor of {@link #processProperties(ConfigurableListableBeanFactory, ConfigurablePropertyResolver)}
159163
* @throws UnsupportedOperationException
160164
*/
161165
@Override
162166
@Deprecated
163-
protected void processProperties(ConfigurableListableBeanFactory beanFactory, java.util.Properties props)
164-
throws BeansException {
167+
protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props) {
165168
throw new UnsupportedOperationException(
166-
"call processProperties(ConfigurableListableBeanFactory, ConfigurablePropertyResolver)");
169+
"Call processProperties(ConfigurableListableBeanFactory, ConfigurablePropertyResolver) instead");
167170
}
168171

169172
}

0 commit comments

Comments
 (0)