
Untitled
By: a guest on
May 16th, 2012 | syntax:
None | size: 0.85 KB | hits: 12 | expires: Never
How to get property values from bundle manifest using BundleContext?
java.util.Dictionary headers = Bundle.getHeaders();
Bundle-Properties:
foo.bar.prefix=MS,
foo.bar.hostname=127.0.0.1,
foo.bar.port=8106,
foo.bar.homepath=/foo/bar/E3,
foo.bar.secure=false,
java.util.Properties properties = new java.util.Properties();
java.util.Dictionary headers = bcontext.getBundle().getHeaders();
String manifest_key = "Bundle-Properties";
String manifest_value = (String) headers.get(manifest_key);
if (manifest_value != null) {
String[] t = manifest_value.split(",");
for (int i = 0; i < t.length; i++) {
String[] u = t[i].split("=");
if (1 < u.length) {
String key = u[0];
String value = u[1];
properties.setProperty(key, value);
}
}
}
Dictionary dict = bundleContext.getBundle().getHeader();