Which part of the spec are you looking at that makes you expect a particular order?
If you have a 1..1 reference and both IFoos are registered when FooConsumer is activated then you'll get the one with the highest service ranking. For a dynamic multiple reference it doesn't really make sense to expect a particular binding order since new services with any service rank may be registered in another thread while the "original" set of services is being bound, so there will be at least two threads binding services. thanks david jencks On Nov 1, 2013, at 6:35 AM, Bruce Jackson <[email protected]> wrote: > Hi All > > I have 2 components, Afoo and Bfoo that both implement the same interface > Ifoo. The component xml for both is shown below: > > <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" > immediate="true" name="AFoo"> > <implementation class="com.myriadgroup.scrtest.AFoo"/> > <service> > <provide interface="com.myriadgroup.scrtest.IFoo"/> > </service> > <property name="service.ranking" type="Integer" value="1"/> > </scr:component> > > > <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" > immediate="true" name="BFoo"> > <implementation class="com.myriadgroup.scrtest.BFoo"/> > <service> > <provide interface="com.myriadgroup.scrtest.IFoo"/> > </service> > <property name="service.ranking" type="Integer" value="2"/> > </scr:component> > > > I have another component FooConsumer that looks up Ifoo instances through > the reference name Foo: > > <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" > name="com.myriadgroup.scrtest"> > <implementation class="com.myriadgroup.scrtest.FooConsumer"/> > <reference cardinality="1..n" interface="com.myriadgroup.scrtest.IFoo" > name="IFoo" policy="static"/> > </scr:component> > > > From what I see in the spec, I would expect the Ifoo instances to be > ordered in terms of the service.ranking when I call > componentContext.locateServices(³Ifoo²). However, this is not the case: > the ordering of the returned component array is entirely arbitrary. > > Can anyone shed any light on this behaviour? > > Thanks > > Bruce > > *** DISCLAIMER *** > > This message, including attachments, is intended solely for the addressee > indicated in this message and is strictly confidential or otherwise > privileged. If you are not the intended recipient (or responsible for > delivery of the message to such person) : - (1) please immediately (i) notify > the sender by reply email and (ii) delete this message and attachments, - (2) > any use, copy or dissemination of this transmission is strictly prohibited. > If you or your employer does not consent to Internet email messages of this > kind, please advise Myriad Group AG by reply e-mail immediately. Opinions, > conclusions and other information expressed in this message are not given or > endorsed by Myriad Group AG unless otherwise indicated by an authorized > representative independent of this message. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

