org.springframework.context.support
Class PropertySourcesPlaceholderConfigurer

java.lang.Object
  extended by org.springframework.core.io.support.PropertiesLoaderSupport
      extended by org.springframework.beans.factory.config.PropertyResourceConfigurer
          extended by org.springframework.beans.factory.config.PlaceholderConfigurerSupport
              extended by org.springframework.context.support.PropertySourcesPlaceholderConfigurer
All Implemented Interfaces:
Aware, BeanFactoryAware, BeanNameAware, BeanFactoryPostProcessor, EnvironmentAware, Ordered, PriorityOrdered

public class PropertySourcesPlaceholderConfigurer
extends PlaceholderConfigurerSupport
implements EnvironmentAware

Specialization of PlaceholderConfigurerSupport

Local properties are added as a property source in any case. Precedence is based on the value of the localOverride property.

Since:
3.1
Author:
Chris Beams
See Also:
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

LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME

public static final String LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME
"localProperties" is the name given to the PropertySource for the set of merged properties supplied to this configurer.

See Also:
Constant Field Values

ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME

public static final String ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME
"environmentProperties" is the name given to the PropertySource that wraps the environment supplied to this configurer.

See Also:
Constant Field Values
Constructor Detail

PropertySourcesPlaceholderConfigurer

public PropertySourcesPlaceholderConfigurer()
Method Detail

setPropertySources

public void setPropertySources(PropertySources propertySources)
Customize the set of PropertySources to be used by this configurer. Setting this property indicates that environment property sources and local properties should be ignored.

See Also:
postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)

setEnvironment

public void setEnvironment(Environment environment)
Set the Environment that this object runs in.

PropertySources from this environment will be searched when replacing ${...} placeholders.

Specified by:
setEnvironment in interface EnvironmentAware
See Also:
setPropertySources(org.springframework.core.env.PropertySources), postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)

postProcessBeanFactory

public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
                            throws BeansException
Merge, convert and process properties against the given bean factory.

Processing occurs by replacing ${...} placeholders in bean definitions by resolving each against this configurer's set of PropertySources, which includes:

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.

Specified by:
postProcessBeanFactory in interface BeanFactoryPostProcessor
Overrides:
postProcessBeanFactory in class PropertyResourceConfigurer
Parameters:
beanFactory - the bean factory used by the application context
Throws:
BeansException - in case of errors

processProperties

protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess,
                                 ConfigurablePropertyResolver propertyResolver)
                          throws BeansException
Visit each bean definition in the given bean factory and attempt to replace ${...} property placeholders with values from the given properties.

Throws:
BeansException

processProperties

@Deprecated
protected void processProperties(ConfigurableListableBeanFactory beanFactory,
                                            Properties props)
Deprecated. in favor of processProperties(ConfigurableListableBeanFactory, ConfigurablePropertyResolver)

Implemented for compatibility with PlaceholderConfigurerSupport.

Specified by:
processProperties in class PropertyResourceConfigurer
Parameters:
beanFactory - the BeanFactory used by the application context
props - the Properties to apply
Throws:
UnsupportedOperationException