The Osgi configurations can be fetched programmatically to be consumed in any service.
Configuration node can be created by creating a node of Type sling:OsgiConfig.
The Osgi configurations can be accessed from http://localhost:4502/system/console/configMgr.
The following code uses ConfigurationAdmin to fetch the config.
@Reference
private ConfigurationAdmin configAdmin;
Configuration cnf=configAdmin.getConfiguration("<name-of-the-Confignode-created>");
Dictionary<String, Object>str=cnf.getProperties(); //To get the properties stored at that node.
String val=str.get("<property-name>"); //To get the specific propert by name
Configuration node can be created by creating a node of Type sling:OsgiConfig.
The Osgi configurations can be accessed from http://localhost:4502/system/console/configMgr.
The following code uses ConfigurationAdmin to fetch the config.
@Reference
private ConfigurationAdmin configAdmin;
Configuration cnf=configAdmin.getConfiguration("<name-of-the-Confignode-created>");
Dictionary<String, Object>str=cnf.getProperties(); //To get the properties stored at that node.
String val=str.get("<property-name>"); //To get the specific propert by name
No comments:
Post a Comment