PropertyConfigurer.java

package util;

import java.util.Properties;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

public class PropertyConfigurer extends PropertyPlaceholderConfigurer {

    private static Properties property = null;

    private static final String JDBC_PASSWORD = "jdbc.password";

    @Override
    protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException {
        try {
            String password = AESCodec.decrypt(props.getProperty(JDBC_PASSWORD));
            props.setProperty(JDBC_PASSWORD, password);
        } catch (Exception e) {
            e.printStackTrace();
        }
        property = props;
        super.processProperties(beanFactoryToProcess, props);
    }

    public static String get(String key) {
        return property.getProperty(key);
    }

}

 

posted @ 2016-01-09 08:12  诚信天下  阅读(259)  评论(0编辑  收藏  举报