You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Joerg Hoh (Jira)" <ji...@apache.org> on 2022/11/14 17:44:00 UTC

[jira] [Comment Edited] (SLING-11029) OSGiServiceInjector.getService() should rely on framework

    [ https://issues.apache.org/jira/browse/SLING-11029?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17633963#comment-17633963 ] 

Joerg Hoh edited comment on SLING-11029 at 11/14/22 5:43 PM:
-------------------------------------------------------------

[~cziegeler] What about using [SlingScriptHelper#getService()|https://github.com/apache/sling-org-apache-sling-scripting-core/blob/4bcf2fdc941029e03470837030cf0cf88a01083d/src/main/java/org/apache/sling/scripting/core/ScriptHelper.java#L206] in this case? It already maintains a reference cache so we have the chance to avoid queries to the ServiceRegistry (which can be costly).


was (Author: joerghoh):
[~cziegeler] What about using [SlingScriptHelper#getService()|https://github.com/apache/sling-org-apache-sling-scripting-core/blob/4bcf2fdc941029e03470837030cf0cf88a01083d/src/main/java/org/apache/sling/scripting/core/ScriptHelper.java#L206] in this case? It already maintains a reference cache so we have the chance too avoid querying the ServiceRegistry (which can be costly).

> OSGiServiceInjector.getService() should rely on framework
> ---------------------------------------------------------
>
>                 Key: SLING-11029
>                 URL: https://issues.apache.org/jira/browse/SLING-11029
>             Project: Sling
>          Issue Type: Improvement
>          Components: Sling Models
>    Affects Versions: Models Implementation 1.5.0
>            Reporter: Carsten Ziegeler
>            Priority: Major
>             Fix For: Models Implementation 1.5.4
>
>
> Looking at https://github.com/apache/sling-org-apache-sling-models-impl/blob/master/src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java#L102 it seems to get all service references, sort them and then uses the one with the highest ranking.
> However BundleContext#getServiceReference() does exactly that, so it can be directly used



--
This message was sent by Atlassian Jira
(v8.20.10#820010)