zoukankan      html  css  js  c++  java
  • web应用中对配置文件的包装

         <bean id="placeholderConfig" class="com.shz.utils.AdvancedPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath:init.properties</value>
                    <value>classpath:api.properties</value>                
                </list>
            </property>
        </bean>
        
         <bean id="systemProperties" class="java.util.HashMap" />

    public class AdvancedPlaceholderConfigurer extends PropertyPlaceholderConfigurer{

        @SuppressWarnings({ "unchecked", "rawtypes" })
        @Override
        protected void processProperties(
                ConfigurableListableBeanFactory beanFactoryToProcess,
                Properties props) throws BeansException {
            
            super.processProperties(beanFactoryToProcess, props);
            
            /******** Set the properties to initProperties object ********/
            HashMap<String, String> systemProperties = (HashMap<String, String>)beanFactoryToProcess.getBean("systemProperties");
            logger.info("starting to load configs into systemProperties object ...");
            Enumeration e = props.propertyNames();
            while (e.hasMoreElements()) {
                String key = (String) e.nextElement();
                systemProperties.put(key,  props.getProperty(key));
            }
            logger.info("finished to load configs into systemProperties object");
        }
        
    }

    public String openAgent(AgentInfoParams forexAgentInfoParams) {
            init();
            try {
                ApplicationContext context = MyContextLoaderListener.getApplicationContext();
                Map<String, String> systemProperties = (Map<String, String>) context.getBean("systemProperties");
                String to = systemProperties.get("constantNZ.forex_cs_agent");
            } catch (Exception e) {
                logger.error("error", e);
                return "ERROR:" + e.getMessage();
            }

            return "OK";
        }


  • 相关阅读:
    美国航天局的十大编码戒律(转)
    大型数据库应用解决方案总结
    IOCP模型
    SSH 连接慢的解决方案详解
    指针(详解)【转】
    有关推挽输出、开漏输出、复用开漏输出、复用推挽输出以及上拉输入、下拉输入、浮空输入、模拟输入区别【转】
    USB入门开发的八个问题&USB枚举『转』
    浅谈 STM32 硬件I2C的使用 (中断方式 无DMA 无最高优先级)(转)
    KEIL Code RO-data RW-data ZI-data 【转】
    262K Color
  • 原文地址:https://www.cnblogs.com/shz365/p/5381968.html
Copyright © 2011-2022 走看看