osgi - 刷新 OSGI 应用程序上下文
问题描述
我正在开发 OSGI 应用程序,我需要在运行时刷新我的 application-context.xml。
我想用
String ctxPath = ....
ApplicationContext ctx = new FileSystemXmlApplicationContext(ctxPath);
((ConfigurableApplicationContext)ctx).refresh();
问题是 - 我找不到获取 application-context.xml 路径的方法(它在 OSGI 包中)。我知道的唯一方法是使用 bundle 的内部文件
InputStream inputStream = new BufferedInputStream(this.getClass().getClassLoader().getResourceAsStream("/application-context.xml"));
但我无法从InputStream
. 任何想法如何使这项工作?
解决方案
我能想象的唯一方法是获取InputStream
(你也可以Bundle.getEntry
为那个),然后将文件保存在你知道路径的地方。我已经在几个应用程序中看到了这种方法,所以我认为它是正确的。
推荐阅读
- docker - Docker停止NPM脚本中的所有容器命令?
- django - Django 错误:NoReverseMatch at / Reverse for 'like-post' 未找到
- reactjs - 抓取网格节点周围的元素时的ReactJS消失
- c++ - 如何检查函数指针是否返回bool
- multithreading - Julia 1.5.2 并行启动随机数选择
- java - 打印直到某个数字的所有素数
- asp.net-mvc - 如何从主视图中的共享视图中获取价值
- node.js - 将 node.js 从 v8 更新到 v12 后加载节点插件时未定义的符号
- r - R - 创建一个循环以通过将列与一列相乘来创建许多表
- kotlin - 防止发生错误时停止 kotlin 流