Configuration properties are available through the org.osgi.service.component.ComponentContext object that is provided on the activation method.
If properties are updated after activation has occurred, the method used for injection depends on the context that the service provides in its OSGi Declarative Services (DS) declaration.
Generally, it is best to declare a method that is to be used specifically for injection of updated properties by using the modified attribute on the service declaration. If a modified method is not available, DS deactivates and then reactivates the service with the new properties.
Deactivating and then activating a service can also cause dependent services to be recycled, and should be avoided unless specifically required. Using the modified attribute is the preferred way to receive configuration updates.
private static Dictionary<String, Object> _props = null;
protected void activate(ComponentContext cc) {
_props = cc.getProperties();
}
protected void modified(Map<?, ?> newProperties) {
if (newProperties instanceof Dictionary) {
_props = (Dictionary<String, Object>) newProperties;
} else {
_props = new Hashtable(newProperties);
}
}