Skip to content

Instantly share code, notes, and snippets.

@RashidJorvee
Last active January 6, 2019 16:32
Show Gist options
  • Save RashidJorvee/c86e3e0d1fa5c79936064aa2d71d6e09 to your computer and use it in GitHub Desktop.
Save RashidJorvee/c86e3e0d1fa5c79936064aa2d71d6e09 to your computer and use it in GitHub Desktop.
How to read configuration from Apache Felix console?
@Activate
protected void activate(final ComponentContext componentContext) throws Exception {
final Map<String, String> properties = (Map<String, String>) componentContext.getProperties();
if (properties != null) {
String uName = PropertiesUtil.toString(properties.get("userName"), "");
int age = PropertiesUtil.toInteger(properties.get("age"), "");
String[] hobbies = PropertiesUtil.toStringArray(properties.get("hobbies"), "");
}
}
ConfigurationAdmin configurationAdmin;
Configuration configuration=null;
configuration=(Configuration)configurationAdmin.getConfiguration("NAME OF THE CONFIGURATION");
Map<String, String> properties = (Map<String, String>) configuration.getProperties();
if (properties != null) {
String uName = properties.get("userName");
int age = properties.get("age");
String[] hobbies = properties.get("hobbies");
}
ConfigurationAdmin configurationAdmin;
Configuration configuration=null;
configuration=(Configuration)configurationAdmin.getConfiguration("NAME OF THE CONFIGURATION");
Map<String, String> properties = (Map<String, String>) configuration.getProperties();
if (properties != null) {
String uName = PropertiesUtil.toString(properties.get("userName"), "");
int age = PropertiesUtil.toInteger(properties.get("age"), "");
String[] hobbies = PropertiesUtil.toStringArray(properties.get("hobbies"), "");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment