[ 
https://issues.apache.org/jira/browse/ARIES-17?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12763530#action_12763530
 ] 

Jarek Gawor commented on ARIES-17:
----------------------------------

As according to JavaDoc, BundleContext.getServiceReference(String) returns a 
best ranked service reference but BundleContext.getServiceReferences(String, 
String) just returns a list of service references, that is, JavaDoc does not 
say anything about the service reference array being ordered in any way. 
ServiceHelper.getService() uses BundleContext.getAllServiceReferences(String, 
String) (and probably should be using getServiceReferences()) and just returns 
the first service in the array. If ServiceHelper.getService() somehow used 
BundleContext.getServiceReference(String) a best ranked service would have been 
returned but since it is using BundleContext.getAllServiceReferences(String, 
String) it must sort the service reference array first.


> ServiceHelper registry lookup problems
> --------------------------------------
>
>                 Key: ARIES-17
>                 URL: https://issues.apache.org/jira/browse/ARIES-17
>             Project: Aries
>          Issue Type: Bug
>          Components: JNDI
>            Reporter: Jarek Gawor
>
> 1) ServiceHelper is using getAllServiceReferences() to get a list of services 
> on the client's bundle context. That can return services which might be 
> incompatible with the bundle classloader.  I think the getServiceReferences() 
> should be used instead.
> 2) The context.lookup("osgi:services/<interface>") should return a best 
> ranking service registered with that interface. However, the 
> ServiceHelper.getService() function seems to return a first service that it 
> finds.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to