<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. Thrift 个人实战--Thrift RPC服务框架日志的优化

    前言: Thrift作为Facebook开源的RPC框架, 通过IDL中间语言, 并借助代码生成引擎生成各种主流语言的rpc框架服务端/客户端代码. 不过Thrift的实现, 简单使用离实际生产环境还 ...

  2. Hive 实战(2)--hive分区分桶实战

    前言: 互联网应用, 当Mysql单机遇到性能瓶颈时, 往往采用的优化策略是分库分表. 由于互联网应用普遍的弱事务性, 这种优化效果非常的显著.而Hive作为数据仓库, 当数据量达到一定数量时, 查询 ...

  3. A candidate solution for Java Web Application - current session

    Motivation Do it once, resue for ever. Audience myself, Java Web developers Scope 应用案例 图书借阅系统 阶段1需求: ...

  4. mysql -workbench : Error cause by ' sql-mode = only-full-group-by'

    当mysql出现"only-full-group-by"问题时,是mysql的sql_mode设置出现了问题. 解决: 1.  找到mysql的 my.cnf文件,我的文件路径是: ...

  5. [HNOI2008],[bzoj1008] 越狱(dp+组合数学)

    题目传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1008 Description 监狱有连续编号为1...N的N个房间,每个房间关押一个犯人 ...

  6. Semantic UI 中文参考手册

    一个拥有友好词汇表的前端框架,完全语义化的前端界面开发框架,为一组开发人员之间共享UI元素配备了规格.使用的词汇(类和ID)相比其它替代品更加简洁,从而降低了学习曲线.有许多HTML元素,UI元素和场 ...

  7. js响应HTML客户端下拉列表的修改事件

    这个案例对经常写前端程序的人来讲应该比较简单,不过像我这种习惯于后台开发,对前端不熟悉的人来说,还是有参考意义的. 在asp.net里面,经常需要响应下拉列表DropDownList的Selected ...

  8. log4net.config

    <?xml version="1.0" encoding="UTF-8"?> <log4net> <root> <le ...

  9. HTML 参考手册

    按字母顺序排列 New : HTML5 中的新标签. 标签 描述 <!--...--> 定义注释. <!DOCTYPE>  定义文档类型. <a> 定义锚. < ...

  10. docker中使用systemd

    由于以下几个原因,docker的官方centos镜像中没有提供systemd服务:   systemd requires the CAP_SYS_ADMIN capability. This mean ...