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

Alexander Klimetschek edited comment on SLING-2575 at 8/28/12 10:48 PM:
------------------------------------------------------------------------

What about integrating the activate/deactivate-less & 
map-instead-of-ServiceReference approach from 
https://fisheye6.atlassian.com/changelog/sling?cs=1377994 in the utility?

Although it IMHO has the disadvantage that it relies on 
o.a.sling.commons.osgi.ServiceUtil [0] re-implementing the same logic as 
ServiceReference.compareTo().

[0] 
http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi/src/main/java/org/apache/sling/commons/osgi/ServiceUtil.java
                
      was (Author: alexander.klimetschek):
    What about integrating the activate/deactivate-less & 
map-instead-of-ServiceReference approach from 
https://fisheye6.atlassian.com/changelog/sling?cs=1377994 in the utility?

(Although it IMHO has the disadvantage that it relies on 
[o.a.sling.commons.osgi.ServiceUtil|http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi/src/main/java/org/apache/sling/commons/osgi/ServiceUtil.java]
 re-implementing the same logic as ServiceReference.compareTo()).
                  
> Utility for tracking a multi-cardinality OSGi service reference
> ---------------------------------------------------------------
>
>                 Key: SLING-2575
>                 URL: https://issues.apache.org/jira/browse/SLING-2575
>             Project: Sling
>          Issue Type: Improvement
>          Components: Commons
>            Reporter: Alexander Klimetschek
>            Priority: Minor
>         Attachments: SLING-2575-ServiceReferences.patch
>
>
> Managing a SCR @Reference that's basically a list is very difficult when 
> compared to the simple unary, static reference. It seems a typical use case 
> is 0..n cardinality, dynamic policy and ordered by service ranking with the 
> higher ranked ones first. This supports the use case to ask a list of 
> services and have the first responding one win.
> There is the ServiceTracker [0], but its getServiceReferences() method does 
> not return the list sorted in any way, only gives your references and not the 
> typed object(s) and it's a bit cumbersome to use.
> A typical manual approach can be seen in the SlingPostServlet [1] in the 
> register*() methods. Important is to handle thread-safeness.
> [0] 
> http://www.osgi.org/javadoc/r4v42/org/osgi/util/tracker/ServiceTracker.html
> [1] 
> http://svn.apache.org/repos/asf/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to