osgi系列之— .properties文件读取
来源:互联网 发布:工厂仿真软件 编辑:程序博客网 时间:2024/05/29 15:09
bundle A 加载osgi context中所有bundle的
application文件夹下.properties的键值对方法
每个bundle独有一个classLoader,在运行环境中,所以考虑将所有bundle的properties中的属性键值对,放置在全局Util类中,供程序使用。
具体方法:
private static String CONFIG_PATH = "configuration";private static String FilePattern = "*.properties";public void init() throws Exception {Bundle[] bds = bundle.getBundleContext().getBundles();for (Bundle b : bds) {Enumeration<URL> e = b.findEntries(CONFIG_PATH, FilePattern, true);if (e != null) {while (e.hasMoreElements()) {URL url = e.nextElement();if (url != null) {InputStream in = url.openStream();try {properties.load(in);} finally {in.close();}}}}}}
Activator.context = bundleContext;Bundle bundle = context.getBundle();String bundleName = bundle.getSymbolicName();FrameworkPropertyHolder propertyHolder = new FrameworkPropertyHolder();propertyHolder.setBundle(bundle);propertyHolder.init();
osgi继承spring后,启动spring容器时,在配置文件中,需要解析通配符${xxx.name}.
需要实现spring的PropertyPlaceholderConfigurer类,下一篇再做具体介绍。
0 0
- osgi系列之— .properties文件读取
- osgi 学习系列(八)osgi读取properties文件
- Java之properties文件读取
- Java系列-如何读取.properties属性文件
- Java系列-读取properties文件连接数据库
- Properties读取properties文件
- Properties 读取 Properties文件
- Java之读取Properties属性文件【整理】
- java之资源文件(.properties)读取
- OSGI系列之mybatis
- Properties文件读取 Message.properties
- 读取properties属性文件——国际化
- 读取中文Properties文件
- properties 文件的读取
- C#读取properties文件
- Java读取Properties文件
- java读取.properties文件
- struts读取.properties文件
- MATLAB系统命令
- Git使用
- 欢迎使用CSDN-markdown编辑器
- 28个Java常用的工具类
- LeetCode----Balanced Binary Tree
- osgi系列之— .properties文件读取
- Swift 可选值(Optional Values)介绍
- MATLAB语言中的关系与逻辑运算
- mac下sublime text 函数跟踪跳转插件
- Universal_image_loader加载网络图片
- 变更svn密码或者用户名
- 在windows上部署使用Redis
- mondrian+Jpviot页面报错
- 如何只授予用户查看存储过程定义的权限