Another option is to make the reference dynamic, but this would force you to 
add lifecycle management code into your component.

Regards,

Tim

Sent from my iPhone

> On 3 Nov 2016, at 07:08, Christian Schneider <ch...@die-schneider.net> wrote:
> 
> References in DS can be reluctant or greedy regarding updates. The default is 
> reluctant which means that once your component is active it will ignore new 
> services coming up.
> See 
> https://osgi.org/javadoc/r5/cmpn/org/osgi/service/component/annotations/Reference.html
> 
> So you need to switch the policy to greedy to see the new service.
> 
> Christian
> 
> 2016-11-03 5:23 GMT+01:00 <manoj.vrajam...@wipro.com>:
>> Hi All,
>> 
>>  
>> 
>> ·         I have written a Service API  ( with method getType() which simply 
>> returns a “serviceString”  in this Interface)
>> 
>> ·         I have written FOUR Service Providers (all implementing the above 
>> interface)
>> 
>> ·         I am able to get the list these FOUR services with the following 
>> function:
>> 
>>     public List<String> getServices(){
>>         return services.stream().map(s -> 
>> s.getType()).collect(Collectors.toList());
>>     }
>> 
>>  
>> 
>> ·         Now,
>> 
>> ·         I create a FIFTH Provider (which implements the same Service API). 
>> Thus I implement  a getType() returning this fifth service string (say 
>> service5)
>> 
>> ·         I install and run this bundle dynamically from the shell using 
>> install / start commands. This FIFTH service is now in active state. (as 
>> seen via ‘lb’ command)
>> 
>>  
>> 
>> ·         But,
>> 
>> ·         I am *UNABLE* to list the FIFTH service by invoking the same 
>> function. It still lists earlier FOUR services only (which are present in 
>> the RunBundle of th e project).
>> 
>>     public List<String> getServices(){
>>         return services.stream().map(s -> 
>> s.getType()).collect(Collectors.toList());
>>     }
>> 
>>  
>> 
>> I want the fifth service to be installed at run time. The function should 
>> list the fifth service as well when called/invoked post installation of the 
>> bundle at run time.
>> 
>>  
>> 
>> Where am I going wrong?  
>> 
>>  
>> 
>> Thanks,
>> 
>> Manoj
>> 
>> The information contained in this electronic message and any attachments to 
>> this message are intended for the exclusive use of the addressee(s) and may 
>> contain proprietary, confidential or privileged information. If you are not 
>> the intended recipient, you should not disseminate, distribute or copy this 
>> e-mail. Please notify the sender immediately and destroy all copies of this 
>> message and any attachments. WARNING: Computer viruses can be transmitted 
>> via email. The recipient should check this email and any attachments for the 
>> presence of viruses. The company accepts no liability for any damage caused 
>> by any virus transmitted by this email. www.wipro.com
>> 
>> _______________________________________________
>> OSGi Developer Mail List
>> osgi-dev@mail.osgi.org
>> https://mail.osgi.org/mailman/listinfo/osgi-dev
> 
> 
> 
> -- 
> -- 
> Christian Schneider
> http://www.liquid-reality.de
> 
> Open Source Architect
> http://www.talend.com
> _______________________________________________
> OSGi Developer Mail List
> osgi-dev@mail.osgi.org
> https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to