首页>代码>大嘴首发J2EE框架,Bigmouth-framework你值得拥有!>/bigmouth/bigmouth-framework/trunk/src/main/java/org/bigmouth/framework/core/SpringContextProperty.java
/*
 * 文件名称: SpringContextProperty.java
 * 版权信息: Copyright 2012 Big-mouth Metro Labs. All right reserved.
 * ----------------------------------------------------------------------------------------------
 * 修改历史:
 * ----------------------------------------------------------------------------------------------
 * 修改原因: 新增
 * 修改人员: Allen.Hu
 * 修改日期: 2012-11-9
 * 修改内容: 
 */
package org.bigmouth.framework.core;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

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


/**
 * <p>
 * <code>
 * 获取Spring上下文中定义的变量值。</br>
 * 在applicationContext.xml中加载properties文件必须使用此类,
 * 否则无法获得指定的变量值。
 * </code>
 * </p>
 * 
 * @author Allen / 2012-9-14
 */
public class SpringContextProperty extends PropertyPlaceholderConfigurer {

    private static Map<String, String> ctxPropertiesMap;

    protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props)
            throws BeansException {
        super.processProperties(beanFactory, props);
        ctxPropertiesMap = new HashMap<String, String>();
        for (Object key : props.keySet()) {
            String keyStr = key.toString();
            String value = props.getProperty(keyStr);
            ctxPropertiesMap.put(keyStr, value);
        }
    }

    public static String getContextProperty(String name) {
        return ctxPropertiesMap.get(name);
    }
}
最近下载更多
ssmss951  LV3 2023年2月27日
微信网友_5970838873509888  LV2 2022年5月24日
hwshws  LV9 2021年5月24日
gyd二蛋不是扁的  LV2 2019年12月11日
huangjiarui  LV11 2019年11月28日
luohaipeng  LV23 2019年11月19日
w2lijing2  LV10 2019年9月16日
等待or进取  LV1 2019年8月24日
低调人  LV38 2019年8月4日
1763157114  LV15 2019年7月8日
最近浏览更多
KWAN112234  LV1 2023年8月18日
ssmss951  LV3 2023年2月27日
微信网友_6248713511227392  LV11 2022年12月5日
微信网友_5970838873509888  LV2 2022年5月24日
你曾是少年啊 2022年2月16日
暂无贡献等级
刘亦菲9527  LV15 2021年12月1日
543666826  LV33 2021年11月18日
好的好的  LV8 2021年6月21日
zxfzxf  LV5 2021年6月21日
jackychen1012  LV2 2021年6月18日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友