On Sep 25, 2012, at 11:56 PM, Chetan Mehrotra wrote:

> Thanks David for those points!!
> 
>> You don't say which kind of annotations you are using (osgi ds, felix ds, or 
>> bnd ds).  I hope its osgi ds :-)
> Well I am used to Felix SCR annotation. Need to start using OSGi DS :)
> 
>> This will work fine.  However, you don't need the dynamic policy as long as 
>> all the CheckReference implementations are available before this manager 
>> component is created.
> But that is not easy to control ... so I typically default to Dynamic Policy
> 
>> Also, at least if you use bnd "next" for the annotation processing, you 
>> don't need to specify the spec version, bnd will figure it out for you.
> 
> Okie. I use Felix SCR Plugin so ther we need to specify that
> 
>> You might not want to instantiate the CheckReferenceImpls unless you 
>> actually want to use one of them.  In this case you can use bind/unbind 
>> methods taking a ServiceReference<CheckReference>  which will give you the 
>> properties you need to decide which one you want, and you can use
>> 
>> componentContext.locateService( "CheckReference", ref )
>> 
>> to get the actual service.
> 
> Good point. Delaying the service instantiation helps. Does
> componentContext.locateService perform an actual lookup everytime by
> querying the OSGi Service registry or it maintains a local copy of
> search results for subsequent calls for those service references.?

In trunk, at the moment, the first time you use locateService it will fetch the 
service object and cache it.  I think the released code does this too but I'm 
less sure.

thanks
david jencks

> 
> regards
> Chetan

Reply via email to