Deprecated
as of 5.2; use org.springframework.context.support.PropertySourcesPlaceholderConfigurer
instead which is more flexible through taking advantage of the org.
and org. mechanisms.
PlaceholderConfigurerSupport subclass that resolves ${...} placeholders against
local properties and/or system properties
and environment variables.
PropertyPlaceholderConfigurer is still appropriate for use when:
spring-context module is not available (i.e., one is using Spring's
BeanFactory API as opposed to ApplicationContext).
"systemPropertiesMode"
and/or "systemPropertiesModeName" properties.
Users are encouraged to move away from using these settings, and rather configure property
source search order through the container's Environment; however, exact preservation
of functionality may be maintained by continuing to use PropertyPlaceholderConfigurer.
setSystemPropertiesModeName, PlaceholderConfigurerSupport, PropertyOverrideConfigurer
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private static final Map | constants
Map of constant names to constant values for the system properties mode constants defined in this class. |
| private boolean | |
| public static final int | SYSTEM_PROPERTIES_MODE_FALLBACK
Check system properties if not resolvable in the specified properties. |
| public static final int | SYSTEM_PROPERTIES_MODE_NEVER
Never check system properties. |
| public static final int | SYSTEM_PROPERTIES_MODE_OVERRIDE
Check system properties first, before trying the specified properties. |
| private int |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected void | processProperties(ConfigurableListableBeanFactory
the BeanFactory used by the application context beanFactoryToProcess, Properties the Properties to apply props)Implements abstract org. Visit each bean definition in the given bean factory and attempt to replace ${...} property placeholders with values from the given properties. |
| protected String | Returns: the resolved value, of null if nonethe placeholder to resolve placeholder, Properties the merged properties of this configurer props, int the system properties mode,
according to the constants in this class systemPropertiesMode)Resolve the given placeholder using the given properties, performing a system properties check according to the given mode. |
| protected String | Returns: the resolved value, ofnull if nonethe placeholder to resolve placeholder, Properties the merged properties of this configurer props)Resolve the given placeholder using the given properties. |
| protected String | Returns: the system property value, ornull if not foundthe placeholder to resolve as system property key key)Resolve the given key as JVM system property, and optionally also as system environment variable if no matching system property has been found. |
| public void | setSearchSystemEnvironment(boolean searchSystemEnvironment)
Set whether to search for a matching system environment variable if no matching system property has been found. |
| public void | setSystemPropertiesMode(int systemPropertiesMode)
Set how to check system properties: as fallback, as override, or never. |
| public void | setSystemPropertiesModeName(String
name of the constant constantName)Set the system property mode by the name of the corresponding constant, e.g. "SYSTEM_PROPERTIES_MODE_OVERRIDE". |
| constants | back to summary |
|---|---|
| private static final Map<String, Integer> constants Map of constant names to constant values for the system properties mode constants defined in this class. | |
| searchSystemEnvironment | back to summary |
|---|---|
| private boolean searchSystemEnvironment | |
| SYSTEM_PROPERTIES_MODE_FALLBACK | back to summary |
|---|---|
| public static final int SYSTEM_PROPERTIES_MODE_FALLBACK Check system properties if not resolvable in the specified properties. This is the default. | |
| SYSTEM_PROPERTIES_MODE_NEVER | back to summary |
|---|---|
| public static final int SYSTEM_PROPERTIES_MODE_NEVER Never check system properties. | |
| SYSTEM_PROPERTIES_MODE_OVERRIDE | back to summary |
|---|---|
| public static final int SYSTEM_PROPERTIES_MODE_OVERRIDE Check system properties first, before trying the specified properties. This allows system properties to override any other property source. | |
| systemPropertiesMode | back to summary |
|---|---|
| private int systemPropertiesMode | |
| PropertyPlaceholderConfigurer | back to summary |
|---|---|
| public PropertyPlaceholderConfigurer() | |
| processProperties | back to summary |
|---|---|
| protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException Implements abstract org. Visit each bean definition in the given bean factory and attempt to replace ${...} property placeholders with values from the given properties.
| |
| resolvePlaceholder | back to summary |
|---|---|
| protected String resolvePlaceholder(String placeholder, Properties props, int systemPropertiesMode) Resolve the given placeholder using the given properties, performing a system properties check according to the given mode. The default implementation delegates to Subclasses can override this for custom resolution strategies, including customized points for the system properties check.
| |
| resolvePlaceholder | back to summary |
|---|---|
| protected String resolvePlaceholder(String placeholder, Properties props) Resolve the given placeholder using the given properties. The default implementation simply checks for a corresponding property key. Subclasses can override this for customized placeholder-to-key mappings or custom resolution strategies, possibly just using the given properties as fallback. Note that system properties will still be checked before respectively after this method is invoked, according to the system properties mode.
| |
| resolveSystemProperty | back to summary |
|---|---|
| protected String resolveSystemProperty(String key) Resolve the given key as JVM system property, and optionally also as system environment variable if no matching system property has been found.
| |
| setSearchSystemEnvironment | back to summary |
|---|---|
| public void setSearchSystemEnvironment(boolean searchSystemEnvironment) Set whether to search for a matching system environment variable if no matching system property has been found. Only applied when "systemPropertyMode" is active (i.e. "fallback" or "override"), right after checking JVM system properties. Default is "true". Switch this setting off to never resolve placeholders against system environment variables. Note that it is generally recommended to pass external values in as JVM system properties: This can easily be achieved in a startup script, even for existing environment variables. | |
| setSystemPropertiesMode | back to summary |
|---|---|
| public void setSystemPropertiesMode(int systemPropertiesMode) Set how to check system properties: as fallback, as override, or never. For example, will resolve ${user.dir} to the "user.dir" system property. The default is "fallback": If not being able to resolve a placeholder with the specified properties, a system property will be tried. "override" will check for a system property first, before trying the specified properties. "never" will not check system properties at all. | |
| setSystemPropertiesModeName | back to summary |
|---|---|
| public void setSystemPropertiesModeName(String constantName) throws IllegalArgumentException Set the system property mode by the name of the corresponding constant, e.g. "SYSTEM_PROPERTIES_MODE_OVERRIDE".
| |
| Modifier and Type | Field and Description |
|---|---|
| private final PropertyPlaceholderHelper | |
| private final PropertyPlaceholderHelper. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String | resolveStringValue(String
the original String value (never strVal)null)Implements org. Resolve the given String value, for example parsing placeholders. |
| helper | back to summary |
|---|---|
| private final PropertyPlaceholderHelper helper | |
| resolver | back to summary |
|---|---|
| private final PropertyPlaceholderHelper. | |
| PlaceholderResolvingStringValueResolver | back to summary |
|---|---|
| public PlaceholderResolvingStringValueResolver(Properties props) | |
| resolveStringValue | back to summary |
|---|---|
| public String resolveStringValue(String strVal) throws BeansException Implements org. Doc from org. Resolve the given String value, for example parsing placeholders. | |
| Modifier and Type | Field and Description |
|---|---|
| private final Properties |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public String | resolvePlaceholder(String
the name of the placeholder to resolve placeholderName)Implements org. Resolve the supplied placeholder name to the replacement value. |
| props | back to summary |
|---|---|
| private final Properties props | |
| PropertyPlaceholderConfigurerResolver | back to summary |
|---|---|
| private PropertyPlaceholderConfigurerResolver(Properties props) | |
| resolvePlaceholder | back to summary |
|---|---|
| public String resolvePlaceholder(String placeholderName) Implements org. Doc from org. Resolve the supplied placeholder name to the replacement value. | |