java.lang.Object | ||||
↳ | org.springframework.core.io.support.PropertiesLoaderSupport | |||
↳ | org.springframework.beans.factory.config.PropertyResourceConfigurer | |||
↳ | org.springframework.beans.factory.config.PlaceholderConfigurerSupport | |||
↳ | org.springframework.beans.factory.config.PropertyPlaceholderConfigurer |
Known Direct Subclasses |
PlaceholderConfigurerSupport
subclass that resolves ${...} placeholders
against local
properties
and/or system properties
and environment variables.
As of Spring 3.1, PropertySourcesPlaceholderConfigurer
should be used preferentially over this implementation; it is
more flexible through taking advantage of the Environment
and
PropertySource
mechanisms also made available in Spring 3.1.
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
.
Prior to Spring 3.1, the <context:property-placeholder/>
namespace element
registered an instance of PropertyPlaceholderConfigurer
. It will still do so if
using the spring-context-3.0.xsd
definition of the namespace. That is, you can preserve
registration of PropertyPlaceholderConfigurer
through the namespace, even if using Spring 3.1;
simply do not update your xsi:schemaLocation
and continue using the 3.0 XSD.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | SYSTEM_PROPERTIES_MODE_FALLBACK | Check system properties if not resolvable in the specified properties. | |||||||||
int | SYSTEM_PROPERTIES_MODE_NEVER | Never check system properties. | |||||||||
int | SYSTEM_PROPERTIES_MODE_OVERRIDE | Check system properties first, before trying the specified properties. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.beans.factory.config.PlaceholderConfigurerSupport
| |||||||||||
From class
org.springframework.core.io.support.PropertiesLoaderSupport
| |||||||||||
From interface
org.springframework.core.Ordered
|
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.beans.factory.config.PlaceholderConfigurerSupport
| |||||||||||
From class
org.springframework.core.io.support.PropertiesLoaderSupport
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Set whether to search for a matching system environment variable
if no matching system property has been found.
| |||||||||||
Set how to check system properties: as fallback, as override, or never.
| |||||||||||
Set the system property mode by the name of the corresponding constant,
e.g.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This method is deprecated.
as of Spring 3.0, in favor of using
resolvePlaceholder(String, Properties)
with PropertyPlaceholderHelper .
Only retained for compatibility with Spring 2.5 extensions.
| |||||||||||
Visit each bean definition in the given bean factory and attempt to replace ${...} property
placeholders with values from the given properties.
| |||||||||||
Resolve the given placeholder using the given properties.
| |||||||||||
Resolve the given placeholder using the given properties, performing
a system properties check according to the given mode.
| |||||||||||
Resolve the given key as JVM system property, and optionally also as
system environment variable if no matching system property has been found.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.beans.factory.config.PlaceholderConfigurerSupport
| |||||||||||
From class
org.springframework.beans.factory.config.PropertyResourceConfigurer
| |||||||||||
From class
org.springframework.core.io.support.PropertiesLoaderSupport
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.beans.factory.BeanFactoryAware
| |||||||||||
From interface
org.springframework.beans.factory.BeanNameAware
| |||||||||||
From interface
org.springframework.beans.factory.config.BeanFactoryPostProcessor
| |||||||||||
From interface
org.springframework.core.Ordered
|
Check system properties if not resolvable in the specified properties. This is the default.
Never check system properties.
Check system properties first, before trying the specified properties. This allows system properties to override any other property source.
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.
NOTE: Access to environment variables does not work on the
Sun VM 1.4, where the corresponding getenv()
support was
disabled - before it eventually got re-enabled for the Sun VM 1.5.
Please upgrade to 1.5 (or higher) if you intend to rely on the
environment variable support.
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.
Set the system property mode by the name of the corresponding constant, e.g. "SYSTEM_PROPERTIES_MODE_OVERRIDE".
constantName | name of the constant |
---|
IllegalArgumentException | if an invalid constant was specified |
---|
This method is deprecated.
as of Spring 3.0, in favor of using resolvePlaceholder(String, Properties)
with PropertyPlaceholderHelper
.
Only retained for compatibility with Spring 2.5 extensions.
Parse the given String value for placeholder resolution.
strVal | the String value to parse |
---|---|
props | the Properties to resolve placeholders against |
visitedPlaceholders | the placeholders that have already been visited during the current resolution attempt (ignored in this version of the code) |
Visit each bean definition in the given bean factory and attempt to replace ${...} property placeholders with values from the given properties.
beanFactoryToProcess | the BeanFactory used by the application context |
---|---|
props | the Properties to apply |
BeansException |
---|
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.
placeholder | the placeholder to resolve |
---|---|
props | the merged properties of this configurer |
null
if noneResolve the given placeholder using the given properties, performing a system properties check according to the given mode.
The default implementation delegates to resolvePlaceholder
(placeholder, props)
before/after the system properties check.
Subclasses can override this for custom resolution strategies, including customized points for the system properties check.
placeholder | the placeholder to resolve |
---|---|
props | the merged properties of this configurer |
systemPropertiesMode | the system properties mode, according to the constants in this class |
Resolve the given key as JVM system property, and optionally also as system environment variable if no matching system property has been found.
key | the placeholder to resolve as system property key |
---|
null
if not found