类 PropertyResourceConfigurer
- java.lang.Object
- org.springframework.core.io.support.PropertiesLoaderSupport
- org.springframework.beans.factory.config.PropertyResourceConfigurer
- 所有已实现的接口:
BeanFactoryPostProcessor
,Ordered
,PriorityOrdered
public abstract class PropertyResourceConfigurer extends PropertiesLoaderSupport implements BeanFactoryPostProcessor, PriorityOrdered
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.- 从以下版本开始:
- 02.10.2003
- 作者:
- Juergen Hoeller
- 另请参阅:
PropertyOverrideConfigurer
,PropertyPlaceholderConfigurer
字段概要
从类继承的字段 org.springframework.core.io.support.PropertiesLoaderSupport
localOverride, localProperties, logger
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 PropertyResourceConfigurer()
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 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()
Get the order value of this object.void
postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
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.从类继承的方法 org.springframework.core.io.support.PropertiesLoaderSupport
loadProperties, mergeProperties, setFileEncoding, setIgnoreResourceNotFound, setLocalOverride, setLocation, setLocations, setProperties, setPropertiesArray, setPropertiesPersister
构造器详细资料
PropertyResourceConfigurer
public PropertyResourceConfigurer()
方法详细资料
setOrder
public void setOrder(int order)
Set the order value of this object for sorting purposes.- 另请参阅:
PriorityOrdered
getOrder
public int getOrder()
从接口复制的说明:Ordered
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.
- 指定者:
getOrder
在接口中Ordered
- 返回:
- the order value
- 另请参阅:
Ordered.HIGHEST_PRECEDENCE
,Ordered.LOWEST_PRECEDENCE
postProcessBeanFactory
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
- 指定者:
postProcessBeanFactory
在接口中BeanFactoryPostProcessor
- 参数:
beanFactory
- the bean factory used by the application context- 抛出:
BeanInitializationException
- if any properties cannot be loadedBeansException
- in case of errors
convertProperties
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(java.lang.String)
for each property value, replacing the original with the converted value.- 参数:
props
- the Properties to convert- 另请参阅:
processProperties(org.springframework.beans.factory.config.ConfigurableListableBeanFactory, java.util.Properties)
convertProperty
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)
.- 参数:
propertyName
- the name of the property that the value is defined forpropertyValue
- the original value from the properties source- 返回:
- the converted value, to be used for processing
- 另请参阅:
convertPropertyValue(String)
convertPropertyValue
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.
- 参数:
originalValue
- the original value from the properties source (properties file or local "properties")- 返回:
- the converted value, to be used for processing
- 另请参阅:
PropertiesLoaderSupport.setProperties(java.util.Properties)
,PropertiesLoaderSupport.setLocations(org.springframework.core.io.Resource...)
,PropertiesLoaderSupport.setLocation(org.springframework.core.io.Resource)
,convertProperty(String, String)
processProperties
protected abstract void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props) throws BeansException
Apply the given Properties to the given BeanFactory.- 参数:
beanFactory
- the BeanFactory used by the application contextprops
- the Properties to apply- 抛出:
BeansException
- in case of errors