felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pierre De Rop <pierre.de...@gmail.com>
Subject Re: multiple configuration dependency
Date Sat, 04 Feb 2012 09:35:43 GMT
Hi Mohica,

After more investigations, there is no bugs, and I forgot to tell you about
the "changed" attribute from the ServiceDependency annotation.

The "changed" attribute allows to define a callback method when the service
properties are updated, so coming back to the second case in the previous
example, where both services are packaged in different bundles, then in
service2, you can define the dependency over service1 using the "changed"
callback attribute, and the service2 "changed" callback will then be
invoked when you update the the service1 configuration:

@Component
public class Service2
{
 // ...

 // Use a ServiceDependency instead of a ConfigurationDependency
 // on Service2, and retrieve service2 configuration using service2
 // osgi service properties.
 // Also define a "changed" callback in order to see service1 service
properties
 // modification

 @ServiceDependency(changed="updateService1")
 void bindService1(Map<String, ?> config, Service1Interfaceservice1)
 {
    System.out.println("Service2 got Service1 properties: " + config);
 }

 void updateService1(Map<String, ?> config, Service1Interfaceservice1)
 {
    System.out.println("Service2 updated with Service1 properties: " +
config);
 }
}

kind regards;
/Pierre



On Tue, Jan 31, 2012 at 10:33 AM, Pierre De Rop <pierre.derop@gmail.com>wrote:

> Hi Mohica,
>
> This sounds like a bug, I will investigate asap.
>
> regards
> /pierre
>
>
> On Mon, Jan 30, 2012 at 9:56 PM, Mohica Jasha <mohica.jasha@gmail.com>wrote:
>
>> On Mon, Jan 30, 2012 at 8:11 AM, Pierre De Rop <pierre.derop@gmail.com
>> >wrote:
>>
>> >     // Use a ServiceDependency instead of a ConfigurationDependency on
>> > Service2, and
>> >     // retrieve service2 configuration using service2 osgi service
>> > properties
>> >    @ServiceDependency
>> >    protected void bindService1(Map<String, ?> config, Service1Interface
>> > service1)
>> >    {
>> >        System.out.println("Service2 got Service1 properties: " +
>> config);
>> >    }
>> > }
>> >
>> >
>> Thanks you very much for you elaborate answer.
>> I think the bindService1 is invoked just once, and if service1's
>> configuration is changed then service2 does not get informed. Am I right?
>> Is there any easy workaround solution for getting updates of service1's
>> configuration?
>>
>> Thanks,
>> Mohica
>>
>>
>>
>>
>> > Hope this helps,
>> > /Pierre
>> >
>> > On Fri, Jan 27, 2012 at 7:00 PM, Mohica Jasha <mohica.jasha@gmail.com
>> > >wrote:
>> >
>> > > I have two OSGi services: service1 and service2 and each has its own
>> > > service PIDs: "service1.pid" and "service2.pid"
>> > >
>> > > service1 only depends on its own configuration, but service2 depends
>> on
>> > > both its configuration and service2 configuration and should also get
>> > > informed of any updates of service2's configuration.
>> > > Is it possible to use dependency manager annotation, i.e.,
>> > > @ConfigurationDependency, to specify both of configuration
>> dependencies
>> > of
>> > > service2?
>> > >
>> > > Thanks in advance,
>> > > M
>> > >
>> >
>>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message