zoukankan      html  css  js  c++  java
  • 简单的读取配置文件的工具类

    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;

     

    public class PropertiesUtil

      extends PropertyPlaceholderConfigurer

    {

      private static Map<String, Object> ctxPropertiesMap = new HashMap();

      

      protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props)

        throws BeansException

      {

        super.processProperties(beanFactoryToProcess, props);

        for (Object key : props.keySet())

        {

          String keyStr = key.toString();

          String value = props.getProperty(keyStr);

          ctxPropertiesMap.put(keyStr, value);

        }

      }

      

      public static Object getContextProperty(String name)

      {

        return ctxPropertiesMap.get(name);

      }

      

      public static String getContexrtParam(String name)

      {

        return (String)ctxPropertiesMap.get(name);

      }

      

      public static void load(Map map)

      {

        if ((map != null) && (!map.isEmpty())) {

          for (Object key : map.keySet()) {

            ctxPropertiesMap.put(key.toString(), map.get(key));

          }

        }

      }

    }

  • 相关阅读:
    享受法国葡萄酒
    shell (bash) hot keys
    传统MapReduce框架
    【oracle】常用命令
    【转】商业J2EE中间件价值何在?
    【转】Linux(CentOS)服务器上安装Webmin
    【转】CentOS 5安装免费主机控制面板Webmin
    【源码】不规则矩形窗体的设计
    【转】虚拟机VirtualBox+Centos+NAT网络的配置过程
    【jsp】 config配置的关键字
  • 原文地址:https://www.cnblogs.com/tom-plus/p/7581439.html
Copyright © 2011-2022 走看看