asset-share-commons
asset-share-commons copied to clipboard
Multiple Cardinality @References do not respect service ranking during binding
It was reported that when a custom SearchProvider Impl was deployed w a high service ranking, it was not first in the @Reference List (in fact is was last).
Need to reaffirm expected behavior, and the expectation of this order is generally important.
@justinedelson do you know what the expected behavior here is off the top of your head? I cant find any docs that state any expected order (so perhaps there is none?)
I believe the order is from lowest ranking to highest ranking. See https://felix.apache.org/apidocs/configadmin/1.4.0/org/osgi/framework/ServiceReference.html#compareTo(java.lang.Object)
So it is likely that you'll need to reverse the order on access. Or use RankedServices
instead of the DS-managed collection.
Does SlingModel's this adhere to Sling Models' osgi service collection as well?
@OSGiService
List<SearchProvider> searchProviders;
it should. See https://github.com/apache/sling-org-apache-sling-models-impl/blob/master/src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java#L100
There was a bug that this didn't work properly in a request-adaptable model. See https://issues.apache.org/jira/browse/SLING-5664. But that was fixed a while ago and should be in 6.3 and above.