20
20
import java .util .Set ;
21
21
22
22
import org .springframework .beans .BeansException ;
23
- import org .springframework .beans .factory .BeanFactoryAware ;
24
- import org .springframework .beans .factory .BeanNameAware ;
25
23
import org .springframework .core .Constants ;
26
24
import org .springframework .util .PropertyPlaceholderHelper ;
27
25
import org .springframework .util .PropertyPlaceholderHelper .PlaceholderResolver ;
28
26
import org .springframework .util .StringValueResolver ;
29
27
30
28
/**
31
- * {@link AbstractPropertyPlaceholderConfigurer } subclass that resolves ${...} placeholders
29
+ * {@link PlaceholderConfigurerSupport } subclass that resolves ${...} placeholders
32
30
* against {@link #setLocation local} {@link #setProperties properties} and/or system properties
33
31
* and environment variables.
34
32
*
39
37
*
40
38
* <p>{@link PropertyPlaceholderConfigurer} is still appropriate for use when:
41
39
* <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}.
49
47
* </ul>
50
48
*
51
49
* <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
54
52
* registration of {@code PropertyPlaceholderConfigurer} through the namespace, even if using Spring 3.1;
55
53
* simply do not update your {@code xsi:schemaLocation} and continue using the 3.0 XSD.
56
54
*
57
55
* @author Juergen Hoeller
58
56
* @author Chris Beams
59
57
* @since 02.10.2003
60
58
* @see #setSystemPropertiesModeName
61
- * @see AbstractPropertyPlaceholderConfigurer
59
+ * @see PlaceholderConfigurerSupport
62
60
* @see PropertyOverrideConfigurer
63
61
* @see org.springframework.context.support.PropertySourcesPlaceholderConfigurer
64
62
*/
65
- public class PropertyPlaceholderConfigurer extends AbstractPropertyPlaceholderConfigurer
66
- implements BeanNameAware , BeanFactoryAware {
63
+ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport {
67
64
68
65
/** Never check system properties. */
69
66
public static final int SYSTEM_PROPERTIES_MODE_NEVER = 0 ;
@@ -140,7 +137,7 @@ public void setSearchSystemEnvironment(boolean searchSystemEnvironment) {
140
137
/**
141
138
* Resolve the given placeholder using the given properties, performing
142
139
* 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
144
141
* (placeholder, props)</code> before/after the system properties check.
145
142
* <p>Subclasses can override this for custom resolution strategies,
146
143
* including customized points for the system properties check.
@@ -209,6 +206,7 @@ protected String resolveSystemProperty(String key) {
209
206
}
210
207
}
211
208
209
+
212
210
/**
213
211
* Visit each bean definition in the given bean factory and attempt to replace ${...} property
214
212
* placeholders with values from the given properties.
@@ -222,6 +220,25 @@ protected void processProperties(ConfigurableListableBeanFactory beanFactoryToPr
222
220
this .doProcessProperties (beanFactoryToProcess , valueResolver );
223
221
}
224
222
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
+
225
242
private class PlaceholderResolvingStringValueResolver implements StringValueResolver {
226
243
227
244
private final PropertyPlaceholderHelper helper ;
@@ -240,23 +257,6 @@ public String resolveStringValue(String strVal) throws BeansException {
240
257
}
241
258
}
242
259
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
- }
260
260
261
261
private class PropertyPlaceholderConfigurerResolver implements PlaceholderResolver {
262
262
0 commit comments