Hi,
I am using DS @Component and trying to get notified through @Modified when
a shared pid file is updated (using felix scr 2.0.2 in karaf 4.0.5)
I defined a configuration interface such as:
@ObjectClassDefinition(pid = "foo.bar")
public @interface MyConfig {
String username() default "myuser";
String url() default "http://localhost:8080";
}
Then, I have 3 differents classes with @Component annotation. All of them
are mapped to this pid "foo.bar".
Please note that each component is defined in separated bundles.
@Component(configurationPid = "foo.bar", immediate = true)
@Designate(ocd = MyConfig.class)
public class CompA implements MyInterfaceA {
@Activate
public void activate(MyConfig myConfig) {
...
}
@Modified
public synchronized void modify(MyConfig myConfig) {
...
}
}
@Component(configurationPid = "foo.bar")
@Designate(ocd = MyConfig.class)
public class CompB implements MyInterfaceB {
@Activate
public void activate(MyConfig myConfig) {
...
}
@Modified
public synchronized void modify(MyConfig myConfig) {
...
}
}
@Component(configurationPid = "foo.bar")
@Designate(ocd = MyConfig.class)
public class CompC implements MyInterfaceC {
@Activate
public void activate(MyConfig myConfig) {
...
}
@Modified
public synchronized void modify(MyConfig myConfig) {
...
}
}
All these 3 components are activated.
When the corresponding pid file foo.bar.cfg is updated, the
modify(MyConfig) method surrounded with the @Modified annotations is
invoked only for one of them.
Moreover, the component that get updated randomly change when restarting
the application.
Question:
- Can @Component(s) of separate bundles be notified through @Modified
annotated methods when a shared pid file is updated?
- Is it possible to achieve this using annotation configuration classes as
I did here with MyConfig class (with DS 1.3)?
- If not possible, is there any alternative solution to achieve this?
Thanks for your help.
Kind Regards,
Christian