You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Paul Spencer <pa...@mindspring.com> on 2021/09/09 16:42:01 UTC
4.3.x JSON based configuration example for an OSGi bundle?
I am looking for a example of getting configuration using Karaf 4.3.x from JSON configuration file. Below is an example, based on Karaf 4.2.x karaf-config-example-scr, of getting the value for “key1” from the configuration file “etc/foo.conf” that I am looking to Karaf 4.3 and JSON.
Ideally the example will include array and map examples for JSON file similar to the following.
{
“Array”: [ “a”,’b”,”c”],
“Map”: {
“key1”: “value 1”,
“key2”: “value 2”
}
}
***
* Karaf 4.2 Bundle Class
***
@Component(configuationPid = “foo”)
…
@Activate
public activate( ComponentContext context) {
String keyValue = context.getProperties().get(“key1”);
}
***
* etc/foo.cfg
***
key1 = value 1
key2 = value 2
Paul Spencer