public abstract class

PropertyResourceConfigurer

extends PropertiesLoaderSupport
implements BeanFactoryPostProcessor PriorityOrdered
java.lang.Object
   ↳ org.springframework.core.io.support.PropertiesLoaderSupport
     ↳ org.springframework.beans.factory.config.PropertyResourceConfigurer
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Allows for configuration of individual bean property values from a property resource, i.e. a properties file. Useful for custom config files targeted at system administrators that override bean properties configured in the application context.

Two concrete implementations are provided in the distribution:

Property values can be converted after reading them in, through overriding the convertPropertyValue(String) method. For example, encrypted values can be detected and decrypted accordingly before processing them.

Summary

[Expand]
Inherited Constants
From class org.springframework.core.io.support.PropertiesLoaderSupport
From interface org.springframework.core.Ordered
[Expand]
Inherited Fields
From class org.springframework.core.io.support.PropertiesLoaderSupport
Public Constructors
PropertyResourceConfigurer()
Public Methods
int getOrder()
Return the order value of this object, with a higher value meaning greater in terms of sorting.
void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
Merge, convert and process properties against the given bean factory.
void setOrder(int order)
Set the order value of this object for sorting purposes.
Protected Methods
void convertProperties(Properties props)
Convert the given merged properties, converting property values if necessary.
String convertProperty(String propertyName, String propertyValue)
Convert the given property from the properties source to the value which should be applied.
String convertPropertyValue(String originalValue)
Convert the given property value from the properties source to the value which should be applied.
abstract void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props)
Apply the given Properties to the given BeanFactory.
[Expand]
Inherited Methods
From class org.springframework.core.io.support.PropertiesLoaderSupport
From class java.lang.Object
From interface org.springframework.beans.factory.config.BeanFactoryPostProcessor
From interface org.springframework.core.Ordered

Public Constructors

public PropertyResourceConfigurer ()

Also: SpringBeans

Public Methods

public int getOrder ()

Also: SpringBeans

Return the order value of this object, with a higher value meaning greater in terms of sorting.

Normally starting with 0, with Integer.MAX_VALUE indicating the greatest value. Same order values will result in arbitrary positions for the affected objects.

Higher values can be interpreted as lower priority. As a consequence, the object with the lowest value has highest priority (somewhat analogous to Servlet "load-on-startup" values).

Returns
  • the order value

public void postProcessBeanFactory (ConfigurableListableBeanFactory beanFactory)

Also: SpringBeans

Merge, convert and process properties against the given bean factory.

Parameters
beanFactory the bean factory used by the application context
Throws
BeanInitializationException if any properties cannot be loaded
BeansException

public void setOrder (int order)

Also: SpringBeans

Set the order value of this object for sorting purposes.

See Also

Protected Methods

protected void convertProperties (Properties props)

Also: SpringBeans

Convert the given merged properties, converting property values if necessary. The result will then be processed.

The default implementation will invoke convertPropertyValue(String) for each property value, replacing the original with the converted value.

Parameters
props the Properties to convert

protected String convertProperty (String propertyName, String propertyValue)

Also: SpringBeans

Convert the given property from the properties source to the value which should be applied.

The default implementation calls convertPropertyValue(String).

Parameters
propertyName the name of the property that the value is defined for
propertyValue the original value from the properties source
Returns
  • the converted value, to be used for processing

protected String convertPropertyValue (String originalValue)

Also: SpringBeans

Convert the given property value from the properties source to the value which should be applied.

The default implementation simply returns the original value. Can be overridden in subclasses, for example to detect encrypted values and decrypt them accordingly.

Parameters
originalValue the original value from the properties source (properties file or local "properties")
Returns
  • the converted value, to be used for processing

protected abstract void processProperties (ConfigurableListableBeanFactory beanFactory, Properties props)

Also: SpringBeans

Apply the given Properties to the given BeanFactory.

Parameters
beanFactory the BeanFactory used by the application context
props the Properties to apply
Throws
BeansException in case of errors