Hi,
I have two implementation implementing the same OSGi service interface. I would like to reference a specific implementation inside a Sling Model using the appropriate injector-specific annotation, which is @OSGiService annotation. But how could I reference the specific service implementation?
If I was coding an OSGi component I would use the @Reference annotation and specify the property "target" as described here: https://edivad.wordpress.com/2013/08/11/cq5osgi-reference-a-unique-service-implementation/
Thank you!
Solved! Go to Solution.
I managed to reference a particular service implemention using the filter property of the injector specific annotation @OSGiService:
@OSGiService(filter="(component.name=com.package.ServiceMockedImpl)")
private Service service;
It is not possible to use SCR within a pojo. But for Sling Models there are possibilities to do it, see [1]. I haven't tried it myself yet, but I guess, it does what you want to do.
Jörg
[1] http://sling.apache.org/documentation/bundles/models.html#available-injectors, look for OSGI services.
Views
Replies
Total Likes
I managed to reference a particular service implemention using the filter property of the injector specific annotation @OSGiService:
@OSGiService(filter="(component.name=com.package.ServiceMockedImpl)")
private Service service;
Views
Likes
Replies
Views
Likes
Replies