!-- <context:property-placeholder --> <!-- location="/WEB-INF/jdbc-config/jdbc.properties" /> --> <bean id="propertyConfigurer" class="com.chinaGPS.nss.util.MyPropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>/WEB-INF/jdbc-config/httpRemote.properties</value> </list> </property> </bean>
package com.chinaGPS.nss.util;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import com.chinaGPS.nss.constant.SystemConst;
/**加载属性类
* @author zhz
*
*/
public class MyPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer {
private Map<String, String> resolvedProps;//将属性保存起来
@Override
protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess,
Properties props) throws BeansException {
super.processProperties(beanFactoryToProcess, props);
resolvedProps = new HashMap<String, String>();
for (Object key : props.keySet()) {
String keyStr = key.toString();
if(StringUtils.equals(keyStr, "auto_craw"))
{
String tmp = parseStringValue(props.getProperty(keyStr), props,new HashSet());
if(StringUtils.equalsIgnoreCase(tmp, "on"))
SystemConst.AUTOCRAW = "on";
if(StringUtils.equalsIgnoreCase(tmp, "off"))
SystemConst.AUTOCRAW="off";
else
continue;
}
// resolvedProps.put(keyStr, parseStringValue(props.getProperty(keyStr), props,
// new HashSet()));
}
}
}