Last active
January 6, 2019 16:32
-
-
Save RashidJorvee/c86e3e0d1fa5c79936064aa2d71d6e09 to your computer and use it in GitHub Desktop.
How to read configuration from Apache Felix console?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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"), ""); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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