Top Description Fields Constructors Methods
org.springframework.beans.factory.config

public abstract Class PropertyResourceConfigurer

extends PropertiesLoaderSupport
implements BeanFactoryPostProcessor, PriorityOrdered
Class Inheritance
All Implemented Interfaces
org.springframework.core.PriorityOrdered, org.springframework.core.Ordered, org.springframework.beans.factory.config.BeanFactoryPostProcessor
Known Direct Subclasses
org.springframework.beans.factory.config.PlaceholderConfigurerSupport, org.springframework.beans.factory.config.PropertyOverrideConfigurer
Imports
java.io.IOException, java.util.Enumeration, .Properties, org.springframework.beans.BeansException, org.springframework.beans.factory.BeanInitializationException, org.springframework.core.Ordered, .PriorityOrdered, org.springframework.core.io.support.PropertiesLoaderSupport, org.springframework.util.ObjectUtils

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 method. For example, encrypted values can be detected and decrypted accordingly before processing them.

Author
Juergen Hoeller
Since
02.10.2003
See Also
PropertyOverrideConfigurer, PropertyPlaceholderConfigurer

Field Summary

Modifier and TypeField and Description
private int
Inherited from org.springframework.core.io.support.PropertiesLoaderSupport:
localOverridelocalPropertieslogger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
convertProperties(Properties
the Properties to convert
props
)

Convert the given merged properties, converting property values if necessary.

protected String

Returns:

the converted value, to be used for processing
convertProperty
(String
the name of the property that the value is defined for
propertyName
,
String
the original value from the properties source
propertyValue
)

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

protected String

Returns:

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

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

public int
getOrder()

Implements org.springframework.core.Ordered.getOrder.

Get the order value of this object.
public void
postProcessBeanFactory(ConfigurableListableBeanFactory
the bean factory used by the application context
beanFactory
)

Implements org.springframework.beans.factory.config.BeanFactoryPostProcessor.postProcessBeanFactory.

Merge, convert and process properties against the given bean factory.
protected abstract void
processProperties(ConfigurableListableBeanFactory
the BeanFactory used by the application context
beanFactory
,
Properties
the Properties to apply
props
)

Apply the given Properties to the given BeanFactory.

public void
setOrder(int order)

Set the order value of this object for sorting purposes.

Inherited from org.springframework.core.io.support.PropertiesLoaderSupport:
loadPropertiesmergePropertiessetFileEncodingsetIgnoreResourceNotFoundsetLocalOverridesetLocationsetLocationssetPropertiessetPropertiesArraysetPropertiesPersister

Field Detail

orderback to summary
private int order

Constructor Detail

PropertyResourceConfigurerback to summary
public PropertyResourceConfigurer()

Method Detail

convertPropertiesback to summary
protected void convertProperties(Properties props)

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

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

Parameters
props:Properties

the Properties to convert

See Also
processProperties
convertPropertyback to summary
protected String convertProperty(String propertyName, String propertyValue)

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

The default implementation calls convertPropertyValue(String).

Parameters
propertyName:String

the name of the property that the value is defined for

propertyValue:String

the original value from the properties source

Returns:String

the converted value, to be used for processing

See Also
convertPropertyValue(String)
convertPropertyValueback to summary
protected String convertPropertyValue(String originalValue)

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:String

the original value from the properties source (properties file or local "properties")

Returns:String

the converted value, to be used for processing

See Also
setProperties, setLocations, setLocation, convertProperty(String, String)
getOrderback to summary
public int getOrder()

Implements org.springframework.core.Ordered.getOrder.

Doc from org.springframework.core.Ordered.getOrder.

Get the order value of this object.

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

Same order values will result in arbitrary sort positions for the affected objects.

Returns:int

the order value

Annotations
@Override
postProcessBeanFactoryback to summary
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException

Implements org.springframework.beans.factory.config.BeanFactoryPostProcessor.postProcessBeanFactory.

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

Parameters
beanFactory:ConfigurableListableBeanFactory

Doc from org.springframework.beans.factory.config.BeanFactoryPostProcessor.postProcessBeanFactory.

the bean factory used by the application context

Annotations
@Override
Exceptions
BeansException:

Doc from org.springframework.beans.factory.config.BeanFactoryPostProcessor.postProcessBeanFactory.

in case of errors

BeanInitializationException:
if any properties cannot be loaded
processPropertiesback to summary
protected abstract void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props) throws BeansException

Apply the given Properties to the given BeanFactory.

Parameters
beanFactory:ConfigurableListableBeanFactory

the BeanFactory used by the application context

props:Properties

the Properties to apply

Exceptions
BeansException:
in case of errors
setOrderback to summary
public void setOrder(int order)

Set the order value of this object for sorting purposes.

See Also
PriorityOrdered