<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";
    }

web应用中对配置文件的包装的更多相关文章

  1. J2EE进阶(五)Spring在web.xml中的配置

     J2EE进阶(五)Spring在web.xml中的配置 前言 在实际项目中spring的配置文件applicationcontext.xml是通过spring提供的加载机制自动加载到容器中.在web ...

  2. Spring web.xml中的配置

    转载博客:http://blog.163.com/zhangke_616/blog/static/191980492007994948206/ 在实际项目中spring的配置文件application ...

  3. Web环境中Spring的启动过程

    1.spring不但可以在JavaSE环境中应用,在Web环境中也可以广泛应用,Spring在web环境中应用时,需要在应用的web.xml文件中添加如下的配置: …… <context-par ...

  4. spring在web.xml中的配置

    在实际项目中spring的配置文件applicationcontext.xml是通过spring提供的加载机制,自动加载的容器中去,在web项目中,配置文件加载到web容器中进行解析,目前,sprin ...

  5. Web 项目 中读取专用配置文件

    在 web 开发中,有时我们要为 业务逻辑处理 配置专用的 配置文件,也就是 xml 文件,这样可以极大的方便维护工作,但是读取 专用的配置文件还需要自己写一个方法,在这里,我封装了一个公用 的方法: ...

  6. Spring中,applicationContext.xml 配置文件在web.xml中的配置详解

    一.首先写一下代码结构. 二.再看web.xml中的配置情况. <?xml version="1.0" encoding="UTF-8"?> < ...

  7. web项目中配置文件的加载顺序

    当一个项目启动时,首先是web.xml: 这里面的配置: 为什么要在web.xml中配置struts的过滤器? 因为一个web项目运行的时需要加载的,或者默认的部分配置都会在web.xml中配置,中间 ...

  8. Web.xml中自动扫描Spring的配置文件及resource时classpath*:与classpath:的区别

    Web.xml中自动扫描Spring的配置文件及resource时classpath*:与classpath:的区别 一.Web.xml中自动扫描Spring的配置文件(applicationCont ...

  9. spring的配置文件在web.xml中加载的方式

    web.xml加载spring配置文件的方式主要依据该配置文件的名称和存放的位置不同来区别,目前主要有两种方式. 1.如果spring配置文件的名称为applicationContext.xml,并且 ...

随机推荐

  1. 有100个节点的AVL树最大深度是多少?

    首先说AVL树的概念 1 左右子树的深度差<=1 2 左右子树都是AVL树. 其实这样算,可以倒推的. 空树  DEPTH = 0; AVL_DEPTH = 2^0+2^1+......+2^k ...

  2. pcl点云文件格式

    PCD版本 在点云库(PCL)1.0版本发布之前,PCD文件格式有不同的修订号.这些修订号用PCD_Vx来编号(例如,PCD_V5.PCD_V6.PCD_V7等等),代表PCD文件的0.x版本号.然而 ...

  3. ✡ leetcode 164. Maximum Gap 寻找最大相邻数字差 --------- java

    Given an unsorted array, find the maximum difference between the successive elements in its sorted f ...

  4. Android——数据库相关(课堂整理)

    layout文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:an ...

  5. linux服务之irqbalance

    irqbalance 理论上:启用 irqbalance 服务,既可以提升性能,又可以降低能耗.irqbalance 用于优化中断分配,它会自动收集系统数据以分析使用模式,并依据系统负载状况将工作状态 ...

  6. 原创:cellmap 基站查询 for android

    cellmap for android 3.6.8.7.9.8 更新日期:2016年12月30日 特别声明:本软件不能进行手机定位,不能对手机号码定位,谨防被骗. 下载地址: cellmap3.6.8 ...

  7. pt-query-digest用法

    pt-query-digest用法 http://blog.csdn.net/wxc20062006/article/details/52387505

  8. [转]Windows多进程编程

    转自:http://blog.csdn.net/bxhj3014/article/details/2082255 一.进程的概念       进程是是一个正在运行的程序的实例(飘---),是系统分配资 ...

  9. DB2导出脚本,重新建立数据库

    在做项目的时候,我们经常会涉及到数据库的迁移 所以我们需要导出 db2数据的建库脚本,存储过程脚本,函数脚本, 我是这么做的 windows键---cmd---进入命令-----db2cmd----进 ...

  10. Linux free命令详解(转)

    解释一下Linux上free命令的输出.(转自:http://www.cnblogs.com/coldplayerest/archive/2010/02/20/1669949.html) 下面是fre ...