|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.core.io.support.PropertiesLoaderSupport org.springframework.beans.factory.config.PropertyResourceConfigurer org.springframework.beans.factory.config.PlaceholderConfigurerSupport org.springframework.context.support.PropertySourcesPlaceholderConfigurer
public class PropertySourcesPlaceholderConfigurer
Specialization of PlaceholderConfigurerSupport
that resolves ${...} placeholders within bean definition
property values and @Value
annotations against the current Spring Environment
and its set of PropertySources
.
This class is designed as a general replacement for PropertyPlaceholderConfigurer
in Spring 3.1 applications. It is used by default to
support the property-placeholder
element in working against the
spring-context-3.1 XSD, whereas spring-context versions <= 3.0 default to
PropertyPlaceholderConfigurer
to ensure backward compatibility. See
spring-context XSD documentation for complete details.
Any local properties (e.g. those added via PropertiesLoaderSupport.setProperties(java.util.Properties)
,
PropertiesLoaderSupport.setLocations(org.springframework.core.io.Resource[])
et al.) are added as a PropertySource
. Search precedence
of local properties is based on the value of the localOverride
property, which is by default false
meaning that local properties are to be
searched last, after all environment property sources.
See ConfigurableEnvironment
and related Javadoc for details on manipulating environment property sources.
ConfigurableEnvironment
,
PlaceholderConfigurerSupport
,
PropertyPlaceholderConfigurer
Field Summary | |
---|---|
static String |
ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME
"environmentProperties" is the name given to the PropertySource that wraps the
environment supplied to this configurer. |
static String |
LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME
"localProperties" is the name given to the PropertySource for the set of
merged properties supplied to this configurer. |
Fields inherited from class org.springframework.beans.factory.config.PlaceholderConfigurerSupport |
---|
DEFAULT_PLACEHOLDER_PREFIX, DEFAULT_PLACEHOLDER_SUFFIX, DEFAULT_VALUE_SEPARATOR, ignoreUnresolvablePlaceholders, nullValue, placeholderPrefix, placeholderSuffix, valueSeparator |
Fields inherited from class org.springframework.core.io.support.PropertiesLoaderSupport |
---|
localOverride, localProperties, logger, XML_FILE_EXTENSION |
Fields inherited from interface org.springframework.core.Ordered |
---|
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE |
Constructor Summary | |
---|---|
PropertySourcesPlaceholderConfigurer()
|
Method Summary | |
---|---|
void |
postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
Merge, convert and process properties against the given bean factory. |
protected void |
processProperties(ConfigurableListableBeanFactory beanFactoryToProcess,
ConfigurablePropertyResolver propertyResolver)
Visit each bean definition in the given bean factory and attempt to replace ${...} property placeholders with values from the given properties. |
protected void |
processProperties(ConfigurableListableBeanFactory beanFactory,
Properties props)
Deprecated. in favor of processProperties(ConfigurableListableBeanFactory, ConfigurablePropertyResolver) |
void |
setEnvironment(Environment environment)
Set the Environment that this object runs in. |
void |
setPropertySources(PropertySources propertySources)
Customize the set of PropertySources to be used by this configurer. |
Methods inherited from class org.springframework.beans.factory.config.PlaceholderConfigurerSupport |
---|
doProcessProperties, setBeanFactory, setBeanName, setIgnoreUnresolvablePlaceholders, setNullValue, setPlaceholderPrefix, setPlaceholderSuffix, setValueSeparator |
Methods inherited from class org.springframework.beans.factory.config.PropertyResourceConfigurer |
---|
convertProperties, convertProperty, convertPropertyValue, getOrder, setOrder |
Methods inherited from class org.springframework.core.io.support.PropertiesLoaderSupport |
---|
loadProperties, mergeProperties, setFileEncoding, setIgnoreResourceNotFound, setLocalOverride, setLocation, setLocations, setProperties, setPropertiesArray, setPropertiesPersister |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME
PropertySource
for the set of
merged properties supplied to this configurer.
public static final String ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME
PropertySource
that wraps the
environment supplied to this configurer.
Constructor Detail |
---|
public PropertySourcesPlaceholderConfigurer()
Method Detail |
---|
public void setPropertySources(PropertySources propertySources)
PropertySources
to be used by this configurer.
Setting this property indicates that environment property sources and local
properties should be ignored.
postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)
public void setEnvironment(Environment environment)
Environment
that this object runs in.
PropertySources
from this environment will be searched when replacing ${...} placeholders.
setEnvironment
in interface EnvironmentAware
setPropertySources(org.springframework.core.env.PropertySources)
,
postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
Processing occurs by replacing ${...} placeholders in bean definitions by resolving each
against this configurer's set of PropertySources
, which includes:
Environment
is present
setPropertySources(org.springframework.core.env.PropertySources)
If setPropertySources(org.springframework.core.env.PropertySources)
is called, environment and local properties will be
ignored. This method is designed to give the user fine-grained control over property
sources, and once set, the configurer makes no assumptions about adding additional sources.
postProcessBeanFactory
in interface BeanFactoryPostProcessor
postProcessBeanFactory
in class PropertyResourceConfigurer
beanFactory
- the bean factory used by the application context
BeansException
- in case of errorsprotected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, ConfigurablePropertyResolver propertyResolver) throws BeansException
BeansException
@Deprecated protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props)
processProperties(ConfigurableListableBeanFactory, ConfigurablePropertyResolver)
PlaceholderConfigurerSupport
.
processProperties
in class PropertyResourceConfigurer
beanFactory
- the BeanFactory used by the application contextprops
- the Properties to apply
UnsupportedOperationException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |