[
https://issues.apache.org/jira/browse/SLING-5041?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15071402#comment-15071402
]
Carsten Ziegeler commented on SLING-5041:
-----------------------------------------
RankedService by itself is useful, there are use cases where you order services
by ranking lowest first, giving the highest the priority by calling it last. It
really depends on the use case.
The latest version of DS can already do what RankedServices does, therefore
using latest DS makes using RankedServices go away.
Therefore I agree with the first point. Let's leave RankedServices as is and
clearly add javadoc that explains how it orders the services (again, the order
is not wrong and we can't call this order not compliant to the OSGi spec, it's
just one way of ordering services). We might or might not add another class
similar to RankedServices for the reverse order. As explained above, I don't
see it as that useful, on the other hand I'm not against it either. But let's
not call it OSGiCompliantRankedServices :) We could add a new constructor to
RankedServices allowing to specify the order (ascending or descending)
> Clarify the order of the iterator given by RankedServices
> ---------------------------------------------------------
>
> Key: SLING-5041
> URL: https://issues.apache.org/jira/browse/SLING-5041
> Project: Sling
> Issue Type: Improvement
> Components: Commons
> Affects Versions: Commons OSGi 2.3.0
> Reporter: Konrad Windszus
>
> Currently the iterator in {{RankedServices}} returns the services in the
> ascending order from lowest to highest ranking. This is a different order
> then being used by OSGi internally [1]. Usually you are only interested in an
> iterator which gives you the service with the highest ranking first (because
> that would also be the one being returned by
> {{BundleContext.getServiceReference(...)}}).
> If we don't change the iterator logic we should at least make it clearer in
> the Javadoc that the iterator really gives the services in ascending order of
> their service ranking property and we should probably add a more useful
> iterator which gives back the services with the highest ranking first.
> The issue came up in the context of SLING-5035.
> [1] -
> https://osgi.org/javadoc/r4v42/org/osgi/framework/BundleContext.html#getServiceReference(java.lang.String)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)