[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [p2-dev] Service ranking and p2's IAgentServiceFactory.

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



Inactive hide details for Gunnar Wagenknecht ---08/01/2012 03:17:21 AM---Am 01.08.2012 04:48, schrieb Mengxin Zhu:Gunnar Wagenknecht ---08/01/2012 03:17:21 AM---Am 01.08.2012 04:48, schrieb Mengxin Zhu:


    From:

Gunnar Wagenknecht <gunnar@xxxxxxxxxxxxxxx>

    To:

p2-dev@xxxxxxxxxxx,

    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
gunnar@xxxxxxxxxxxxxxx
http://wagenknecht.org/

_______________________________________________
p2-dev mailing list
p2-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/p2-dev



GIF image

GIF image