|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.springframework.beans.factory.config.PropertyResourceConfigurer
Allows for configuration of individual bean property values from a property resource, i.e. a properties file. Useful for custom config files targetted at system administrators that override bean properties configured in the application context.
2 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.
PropertyOverrideConfigurer,
PropertyPlaceholderConfigurer,
convertPropertyValue(java.lang.String)| Field Summary | |
protected Log |
logger
|
| Constructor Summary | |
PropertyResourceConfigurer()
|
|
| Method Summary | |
protected void |
convertProperties(Properties props)
Convert the given merged properties, converting property values if necessary. |
protected String |
convertPropertyValue(String originalValue)
Convert the given property value from the properties source to the value that should be applied. |
int |
getOrder()
Return the order value of this object, higher value meaning greater in terms of sorting. |
void |
postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
Modify the application context's internal bean factory after its standard initialization. |
protected abstract void |
processProperties(ConfigurableListableBeanFactory beanFactory,
Properties props)
Apply the given Properties to the bean factory. |
void |
setFileEncoding(String encoding)
Set the encoding to use for parsing properties files. |
void |
setIgnoreResourceNotFound(boolean ignoreResourceNotFound)
Set if failure to find the property resource should be ignored. |
void |
setLocation(Resource location)
Set a location of a properties file to be loaded. |
void |
setLocations(Resource[] locations)
Set locations of properties files to be loaded. |
void |
setOrder(int order)
|
void |
setProperties(Properties properties)
Set local properties, e.g. via the "props" tag in XML bean definitions. |
void |
setPropertiesPersister(PropertiesPersister propertiesPersister)
Set the PropertiesPersister to use for parsing properties files. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected final Log logger
| Constructor Detail |
public PropertyResourceConfigurer()
| Method Detail |
public void setOrder(int order)
public int getOrder()
OrderedHigher value can be interpreted as lower priority, consequently the first object has highest priority (somewhat analogous to Servlet "load-on-startup" values).
getOrder in interface Orderedpublic void setProperties(Properties properties)
setLocation(org.springframework.core.io.Resource),
setLocations(org.springframework.core.io.Resource[])public void setLocation(Resource location)
setLocations(org.springframework.core.io.Resource[])public void setLocations(Resource[] locations)
setLocation(org.springframework.core.io.Resource)public void setFileEncoding(String encoding)
PropertiesPersister.load(java.util.Properties, java.io.InputStream)public void setPropertiesPersister(PropertiesPersister propertiesPersister)
DefaultPropertiesPersisterpublic void setIgnoreResourceNotFound(boolean ignoreResourceNotFound)
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
throws BeansException
BeanFactoryPostProcessor
postProcessBeanFactory in interface BeanFactoryPostProcessorbeanFactory - the bean factory used by the application context
BeansException - in case of errorsprotected void convertProperties(Properties props)
Default implementation will invoke convertPropertyValue
for each property value, replacing the original with the converted value.
convertPropertyValue(java.lang.String),
processProperties(org.springframework.beans.factory.config.ConfigurableListableBeanFactory, java.util.Properties)protected String convertPropertyValue(String originalValue)
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")
setProperties(java.util.Properties),
setLocations(org.springframework.core.io.Resource[]),
setLocation(org.springframework.core.io.Resource)
protected abstract void processProperties(ConfigurableListableBeanFactory beanFactory,
Properties props)
throws BeansException
beanFactory - the bean factory 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 | ||||||||||