[
https://issues.apache.org/jira/browse/SLING-5664?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15244067#comment-15244067
]
Konrad Windszus edited comment on SLING-5664 at 4/16/16 7:41 AM:
-----------------------------------------------------------------
Attached is a patch which makes sure that
# for array injections the service with the highest ranking is returned first
(and afterwards the array is sorted descending by service order)
# and for single value injections only the service with the highest ranking is
injected
Also I added an IT to verify this behaviour.
Due to SLING-5665 I had to remove usage of {{SlingScriptHelper}} in the
injector completely as this does currently not give any opportunity to figure
out the service ranking.
was (Author: kwin):
Attached is a patch which makes sure that
# for array injections the service with the highest ranking is returned first
(and afterwards the array is sorted descending by service order)
# and for single value injections only the service with the highest ranking is
injected
Also I added an IT to verify this behaviour.
Due to SLING-5665 I had to remove usage of `SlingScriptHelper` in the injector
completely as this does currently not give any opportunity to figure out the
service ranking.
> Models: OSGiServiceInjector does not consider service.ranking
> -------------------------------------------------------------
>
> Key: SLING-5664
> URL: https://issues.apache.org/jira/browse/SLING-5664
> Project: Sling
> Issue Type: Bug
> Components: Extensions
> Affects Versions: Sling Models Impl 1.2.6
> Reporter: Konrad Windszus
> Fix For: Sling Models Impl 1.2.8
>
> Attachments: SLING-5664-v01.patch
>
>
> The injector is using {{BundleContext.getServiceReferences(Class, String)}}
> or {{SlingScriptHelper.getServices(Class, String)}}
> (https://github.com/apache/sling/blob/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java#L97).
> From the returned array it just takes the first item.
> Unfortunately the order in that array is not-deterministic, especially it is
> not necessarily that way that items with a higher service.ranking are
> returned first.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)