@Property(boolValue = false/true)
public static final String XYZ_PROPERTY = “xyz.property”;
private boolean xyz;
Retrieving these properties is also simple, you can simply do it like this
@Activate
public void activate(final Map<String, String> properties) {
this.xyz = PropertiesUtil.toBoolean(properties.get(XYZ_PROPERTY ), false);
}
But sometimes you will run into situations where you would need to override these values from OSGI config. If you remove the boolValue from property annotation then the property will be treated as String instead of Boolean.
Example: you want checkbox checked for this above property from OSGI and you somehow don’t want to do it via code because this might change for environments
In your run mode file, if you have the below property and boolValue within the property annotation in the code, you are sorted.
xyz.property=”{Boolean}true”
No comments:
Post a Comment
If you have any doubts or questions, please let us know.