读书人

满载spring中的PropertyPlaceholderCo

发布时间: 2012-09-14 11:53:44 作者: rapoo

重载spring中的PropertyPlaceholderConfigurer,获得加载的属性

今天又重载了PropertyPlaceholderConfigurer,为了把properties中的值拿出来,我重新了processProperties()方法。

获得属性值:

spring 2.x:parseStringValue(props.getProperty(keyStr), props,new HashSet());

spring 3.x: resolvePlaceholder(keyStr, props);

parseStringValue 方法已过时。。。

1 楼 yangshiman 2012-02-10 protected void processProperties(
ConfigurableListableBeanFactory beanFactoryToProcess,
Properties props) throws BeansException {
super.processProperties(beanFactoryToProcess,props);
for (Enumeration propertyNames = props.propertyNames(); propertyNames.hasMoreElements();) {
String propertyName = (String) propertyNames.nextElement();
String propertyValue = props.getProperty(propertyName);
String convertedValue = convertProperty(propertyName, propertyValue);
PropertiesPool.load(propertyName, convertedValue);
}
} 2 楼 qq123zhz 2012-02-10 yangshiman 写道protected void processProperties(
ConfigurableListableBeanFactory beanFactoryToProcess,
Properties props) throws BeansException {
super.processProperties(beanFactoryToProcess,props);
for (Enumeration propertyNames = props.propertyNames(); propertyNames.hasMoreElements();) {
String propertyName = (String) propertyNames.nextElement();
String propertyValue = props.getProperty(propertyName);
String convertedValue = convertProperty(propertyName, propertyValue);
PropertiesPool.load(propertyName, convertedValue);
}
}

你是直接遍历了

读书人网 >编程

热点推荐