Я не знаю, может ли это помочь, но вы можете разработать org.osgi.service.cm.ConfigurationPlugin
для перехвата всех свойств, которые вводятся во время выполнения, и изменения их:
public class MyConfigurationPlugin implements BundleActivator, ConfigurationPlugin {
ServiceRegistration<ConfigurationPlugin> configPluginRef;
@Override
public void start(BundleContext context) throws Exception {
//... init the config plugin
Map<String,String> properties = new HashMap<>();
configPluginRef = context.registerService(
ConfigurationPlugin.class,
this,
new Hashtable<>(properties));
}
@Override
public void modifyConfiguration(ServiceReference<?> reference,
Dictionary<String, Object> properties) {
/*
* View and possibly modify a set of configuration properties
* before they are sent to the Managed Service or the Managed Service Factory.
*/
}
}
Конечно, подход декларативного обслуживания гораздо проще:
@Component (
service= {},
configurationPid={
configPid1,
configPid2,
...
})
public class MyComponent {
@Activate
public void activate(BundleContext context, Map<String, String> properties) {
}
@Modified
public void updated(BundleContext context, Map<String, String> properties) {
// Called when properties change
}
}
но в этом случае вы не можете изменять значения свойств: вы можете реагировать только на изменения свойств.