Gunnar is correct with respect to the OSGi specification. As an implementation detail the snapshot of the service references returned by Equinox's implementation of BundleContext.getServiceReferences(...) will be sorted according to the service ranking at the time of the call such that the first element in the array (or Collection interator) will be the highest ranked service.
Tom |------------> | From: | |------------> >--------------------------------------------------------------------------------------------------------------------------------------------------| |Gunnar Wagenknecht <[email protected]> | >--------------------------------------------------------------------------------------------------------------------------------------------------| |------------> | To: | |------------> >--------------------------------------------------------------------------------------------------------------------------------------------------| |[email protected], | >--------------------------------------------------------------------------------------------------------------------------------------------------| |------------> | Date: | |------------> >--------------------------------------------------------------------------------------------------------------------------------------------------| |08/01/2012 03:17 AM | >--------------------------------------------------------------------------------------------------------------------------------------------------| |------------> | Subject: | |------------> >--------------------------------------------------------------------------------------------------------------------------------------------------| |Re: [p2-dev] Service ranking and p2's IAgentServiceFactory. | >--------------------------------------------------------------------------------------------------------------------------------------------------| Am 01.08.2012 04:48, schrieb Mengxin Zhu: > P2 is searching services via OSGi API that would sort the service > implementations by their ranking. At least in the code snippets posted p2 uses BundleContext#getServiceReferences(...). Nothing in the contract of those methods states that the result returned is sorted in any way. One either needs sort the results (ServiceReference implements Comparable) or switch to using a ServiceTracker which honors service ranking in ServiceTracker#getServiceReference(). -Gunnar -- Gunnar Wagenknecht [email protected] http://wagenknecht.org/ _______________________________________________ p2-dev mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/p2-dev
<<inline: graycol.gif>>
<<inline: ecblank.gif>>
_______________________________________________ p2-dev mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/p2-dev
