Perhaps, it is more appropriate to use Object[] locateServices(String name) method, which will give you access the list of the services. The specification doesn't mandate that the array is sorted, but it should be easy to do.
Perhaps, in this case, you can combine bindXXX() methods with this method to accomplish what you suggest, if you really need to take action on bind and unbind. Personally, I haven't encountered case, where I want to track the multiple references bound to the component manually, I just rely on the locateServices(String name) method. But also, I don't have much experience in using DS... BR, -- Danail Nachev Lead Software Engineer/Development Tools ProSyst Labs EOOD ------------------------------------------------- stay in touch with your product. ------------------------------------------------- On 1/14/2011 12:27 PM, Carsten Ziegeler wrote: > Hi, > > I'm not so sure if this is a great idea, but nevertheless I want to > share it with you :) > > Usually when we're using DS with a reference of cardinality > multiplicity, we need a lot of code to handle this case. As we often > have a cardinality of 0..n for the reference, it means that services can > be bound before or after the component is activated - especially the > before is the harder part. (Well, it's not rocket science but anyway it > takes some lines of code) > And in most cases, we want to have the services ordered by service > ranking, so whenever a service arrives or disappears we have to update > and sort the array (ok when removing we don't need to resort). > > If I compare this to the nice and easy service tracker, I'm always > tempted to use that one instead (which of course I can do as I can mix > things). > > So, what do you think about an alternative way of binding services? > Instead of having a bind/unbind method which gets a single reference, > having a method which gets a sorted array, like > > void bindServices(ServiceReference[] refs) > > or > > void bindServices(ServiceInterface[] services) > > So, in this case, there is no unbind method, but just this single method > that gets called everytime the reference changes. > > That's just a rouhg idea. WDYT? > > Regards > Carsten _______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
