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 != nul