<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. codeforces105d Bag of mice ——概率DP

    Link: http://codeforces.com/problemset/problem/148/D Refer to: http://www.cnblogs.com/kuangbin/archi ...

  2. 快速开发CSS的利器-LESS

    快速开发CSS的利器-LESS? 天下功夫,唯快不破!效率,在项目开发上,这是极其重要的.要做到快.精.准,在人任何时候都不是一件轻松容易的事.但是如果借助一些相应的工具,那就另当别论了!那么要想快速 ...

  3. CentOS中Device eth0 does not seem to be present错误解决办法

    今天克隆的虚拟机,当需要多台虚拟机的时候,试用克隆真是方便,不过遇到了 Device eth0 does not seem to be present 的问题,在网上找到遇到同样问题的解决方法, 很顺 ...

  4. Python chr() ord() unichr()

    chr()函数用一个范围在range(256)内的(就是0-255)整数作参数,返回一个对应的字符. unichr()跟它一样,只不过返回的是Unicode字符,这个从Python 2.0才加入的un ...

  5. 10 个最适合 Web 和 APP 开发的 NodeJS 框架

    在浏览器以外运行 JavaScript 对于 JavaScript 爱好者来说非常神奇,同时也肯定是 web 应用程序开发界最受欢迎的进步之一.全球各地的开发者张开双臂拥抱 NodeJS. 对于新手来 ...

  6. 【转】linux 编译安装nginx,配置自启动脚本

    linux 编译安装nginx,配置自启动脚本 本文章来给各位同学介绍一篇关于linux 编译安装nginx,配置自启动脚本教程,希望有需要了解的朋友可一起来学习学习哦. 在公司的suse服务器装ng ...

  7. [Spring MVC] - Interceptor 拦截器

    Spring MVC中的Interceptor与Struts2的差不多. 下面是一个简单的Interceptor登陆验证例子: 1.需要在spring的配置文件中加入这段: <!-- 自定义拦截 ...

  8. MySQL查询今天/昨天/本周、上周、本月、上个月份数据的sql代码

    MySQL查询本周.上周.本月.上个月份数据的sql代码 作者: 字体:[增加 减小] 类型:转载 时间:2012-11-29我要评论 MySQL查询的方式很多,下面为您介绍的MySQL查询实现的是查 ...

  9. Python---MySQL相关操作

    MySQL数据库操作 显示数据 SHOW DATABASES; #默认数据库: #mysql - 用户权限相关数据 #test - 用于用户测试数据 #information_schema - MyS ...

  10. Eclipse插件SVN配置

    Eclipse插件SVN配置 方法一 打开Eclipse点击[Help]-[Install New Software] 点击右边[Add]-在弹出窗口中输入 Name:svn Location:htt ...