|
|||||||||
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
public abstract class PropertyResourceConfigurer
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:
PropertyOverrideConfigurer
for "beanName.property=value" style overriding
(pushing values from a properties file into bean definitions)
PropertyPlaceholderConfigurer
for replacing "${...}" placeholders
(pulling values from a properties file into bean definitions)
Property values can be converted after reading them in, through overriding
the convertPropertyValue(java.lang.String)
method. For example, encrypted values
can be detected and decrypted accordingly before processing them.
PropertyOverrideConfigurer
,
PropertyPlaceholderConfigurer
Field Summary |
---|
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 | |
---|---|
PropertyResourceConfigurer()
|
Method Summary | |
---|---|
protected void |
convertProperties(Properties props)
Convert the given merged properties, converting property values if necessary. |
protected String |
convertProperty(String propertyName,
String propertyValue)
Convert the given property from the properties source to the value which should be applied. |
protected String |
convertPropertyValue(String originalValue)
Convert the given property value from the properties source to the value which should be applied. |
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. |
protected abstract void |
processProperties(ConfigurableListableBeanFactory beanFactory,
Properties props)
Apply the given Properties to the given BeanFactory. |
void |
setOrder(int order)
Set the order value of this object for sorting purposes. |
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 |
Constructor Detail |
---|
public PropertyResourceConfigurer()
Method Detail |
---|
public void setOrder(int order)
PriorityOrdered
public int getOrder()
Ordered
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).
getOrder
in interface Ordered
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
postProcessBeanFactory
in interface BeanFactoryPostProcessor
beanFactory
- the bean factory used by the application context
BeanInitializationException
- if any properties cannot be loaded
BeansException
- in case of errorsprotected void convertProperties(Properties props)
The default implementation will invoke convertPropertyValue(java.lang.String)
for each property value, replacing the original with the converted value.
props
- the Properties to convertprocessProperties(org.springframework.beans.factory.config.ConfigurableListableBeanFactory, java.util.Properties)
protected String convertProperty(String propertyName, String propertyValue)
The default implementation calls convertPropertyValue(String)
.
propertyName
- the name of the property that the value is defined forpropertyValue
- the original value from the properties source
convertPropertyValue(String)
protected String convertPropertyValue(String originalValue)
The default implementation simply returns the original value. Can be overridden in subclasses, for example to detect encrypted values and decrypt them accordingly.
originalValue
- the original value from the properties source
(properties file or local "properties")
PropertiesLoaderSupport.setProperties(java.util.Properties)
,
PropertiesLoaderSupport.setLocations(org.springframework.core.io.Resource[])
,
PropertiesLoaderSupport.setLocation(org.springframework.core.io.Resource)
,
convertProperty(String, String)
protected abstract void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props) throws BeansException
beanFactory
- the BeanFactory used by the application contextprops
- the Properties to apply
BeansException
- in case of errors
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |