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";
}
web应用中对配置文件的包装的更多相关文章
- J2EE进阶(五)Spring在web.xml中的配置
J2EE进阶(五)Spring在web.xml中的配置 前言 在实际项目中spring的配置文件applicationcontext.xml是通过spring提供的加载机制自动加载到容器中.在web ...
- Spring web.xml中的配置
转载博客:http://blog.163.com/zhangke_616/blog/static/191980492007994948206/ 在实际项目中spring的配置文件application ...
- Web环境中Spring的启动过程
1.spring不但可以在JavaSE环境中应用,在Web环境中也可以广泛应用,Spring在web环境中应用时,需要在应用的web.xml文件中添加如下的配置: …… <context-par ...
- spring在web.xml中的配置
在实际项目中spring的配置文件applicationcontext.xml是通过spring提供的加载机制,自动加载的容器中去,在web项目中,配置文件加载到web容器中进行解析,目前,sprin ...
- Web 项目 中读取专用配置文件
在 web 开发中,有时我们要为 业务逻辑处理 配置专用的 配置文件,也就是 xml 文件,这样可以极大的方便维护工作,但是读取 专用的配置文件还需要自己写一个方法,在这里,我封装了一个公用 的方法: ...
- Spring中,applicationContext.xml 配置文件在web.xml中的配置详解
一.首先写一下代码结构. 二.再看web.xml中的配置情况. <?xml version="1.0" encoding="UTF-8"?> < ...
- web项目中配置文件的加载顺序
当一个项目启动时,首先是web.xml: 这里面的配置: 为什么要在web.xml中配置struts的过滤器? 因为一个web项目运行的时需要加载的,或者默认的部分配置都会在web.xml中配置,中间 ...
- Web.xml中自动扫描Spring的配置文件及resource时classpath*:与classpath:的区别
Web.xml中自动扫描Spring的配置文件及resource时classpath*:与classpath:的区别 一.Web.xml中自动扫描Spring的配置文件(applicationCont ...
- spring的配置文件在web.xml中加载的方式
web.xml加载spring配置文件的方式主要依据该配置文件的名称和存放的位置不同来区别,目前主要有两种方式. 1.如果spring配置文件的名称为applicationContext.xml,并且 ...
随机推荐
- [原创] 用两个stack实现queue的功能
#include <iostream> #include <stack> using namespace std; class doubleStackToQueue { pri ...
- input屏蔽历史记录
设置input 的扩展属性 autocomplete为off即可 <input type="text" autocomplete="off" />
- xmind的第九天笔记
- Java笔记6-数组
知识大纲一.数组的应用由于数组是用来存储数据的,所以,它的操作总是增.删除.改.查的操作.数组做为一种最基本的数据结构,它在查询上效率是最高的.但是在增加.删除的操作效率是最低的. 因为,数组的长度一 ...
- C# 各种数据类型的最大值和最小值常数
using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.IO ...
- LeetCode() Repeated DNA Sequences 看的非常的过瘾!
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...
- 排序算法总结(四)快速排序【QUICK SORT】
感觉自己这几篇都是主要参考的Wikipedia上的,快排就更加是了....wiki上的快排挺清晰并且容易理解的,需要注意的地方我也添加上了注释,大家可以直接看代码.需要注意的是,wikipedia上快 ...
- 【转载】Hadoop机架感知
转载自http://www.cnblogs.com/ggjucheng/archive/2013/01/03/2843015.html 背景 分布式的集群通常包含非常多的机器,由于受到机架槽位和交换机 ...
- finally语句总是不会被执行?
答案是否(1)try语句没有被执行到,如在try语句之前return就返回了,这样finally语句就不会执行.这也说明了finally语句被执行的必要而非充分条件是:相应的try语句一定被执行到.( ...
- ubuntu12.04+proftpd1.3.4a的系统用户+虚拟用户权限应用实践
目录: 一.什么是Proftpd? 二.Proftpd的官方网站在哪里? 三.在哪里下载? 四.如何安装? 1)系统用户的配置+权限控制 2)虚拟用户的配置+权限控制 一.什么是Proftpd? ...