On Tuesday 12 September 2017 14:47:22 Stefan Seifert wrote: > consider the following use case: > - an OSGi/Sling-based library provides a SPI interface > - applications of multiple tenants are deployed on the same instance > - each tenant uses a different content tree, e.g. /content/tenant1 and > /content/tenant2 - each tenant's application wants to register a different > implementation of the SPI, to be applied on resource requests on the > tenant's content subtree - this affects not only one SPI but multiple SPIs > - we do not want to implement a > detect-the-matching-SPI-implementation-for-a-given resource for each > library again - we want to have a configuration of the mapping tenant's > resource path -> SPI implementation in a central place and to be applied to > all SPI implementation of a tenant's application > > i've implemented a solution for this some months ago, it's currently part of > a wcm.io library. documentation [1], source code [2] > > questions: > 1. do you have these use cases as well? (we had a lot of enterprise projects > where we needed exactly this in the last years)
Sure. Nearly the same in my current project: all tentants use the same SPI implementation but only one wants to use a custom one. > 2. does it make sense to > contribute it to sling? +1 > 3. do you have better ideas for configuring the mapping or the > implementation? No, but there was a discussion on SO some years ago about dynamic filtering of services (which is similar but more general – not limited to resources): https://stackoverflow.com/questions/17075938/put-dynamic-osgi-service-selection-in-its-own-service Regards, O. > stefan > > [1] http://wcm.io/sling/commons/context-aware-services.html > [2] > https://github.com/wcm-io/wcm-io-sling/tree/develop/commons/src/main/java/i > o/wcm/sling/commons/caservice