Hi,

I did more tests and I noticed the following behavior with karaf 4.0.8 and
scr 2.0.6 (which does not occur with karaf 4.0.5 and scr 2.0.2).

Having a simple pid defined as:

@ObjectClassDefinition(pid = "foo.bar")
public @interface MyConfig {
    String username() default "myuser";
    String url() default "http://localhost:8080";;
}

And a simple @Component bind to it:

@Component(configurationPid = "foo.bar")
@Designate(ocd = MyConfig.class)
public class CompA implements MyInterfaceA {

    @Activate
    public void activate(MyConfig myConfig) {
...
    }

    @Modified
    public synchronized void modify(MyConfig myConfig) {
...
    }
}

When starting karaf 4.0.8, the @Activate method of my component in invoked
Then, I update the foo.bar.cfg pid file to change a property.
>From time to time and only for the first pid manual update:
- the first update is detected by fileinstall, however, the @Modified
related method of the @Component(configurationPid = "foo.bar") is not
invoked.
- using the config:property-list shows the right updated value.
- updating and saving the file a second time triggers the @Modified
annotated method of that component.

This happens only from time to time when restarting karaf.

I cannot reproduce this issue with karaf 4.0.5

Question:
- Did someone already noticed this?
- Is it a regression?

Thanks
Kind Regards,
Christian


On Mon, Jan 9, 2017 at 1:06 PM, Christian Wolf <[email protected]>
wrote:

> Hi Carsten,
>
> Thanks for your quick answer.
>
> I've just tested with latest karaf 4.0.8 which ships with scr 2.0.6
> => It is working now without changing any piece of code.
> It seems that a fix has been provided between 2.0.2 and 2.0.6.
>
> Thanks for you advice
>
> Kind Regards,
> Christian
>
> On Mon, Jan 9, 2017 at 10:38 AM, Carsten Ziegeler <[email protected]>
> wrote:
>
>> Hi,
>>
>> I think this should be possible the way you do it, so that's a "yes" to
>> the first two of your questions at the end :)
>>
>> Before we start to look for a bug in the implementation, could you
>> please check the scr 2.0.6 release and see whether it's already fixed
>> there?
>> If not, please open a jira ticket.
>>
>> Regards
>> Carsten
>>
>> Christian Wolf wrote
>> > 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
>> >
>>
>>
>>
>>
>> --
>> Carsten Ziegeler
>> Adobe Research Switzerland
>> [email protected]
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>

Reply via email to