Nivel 1
Nivel 2
Iniciar sesión en la comunidad
Iniciar sesión para ver todas las insignias
Hello Experience League Community,
I’m currently working with Sling Models and came across the @OsgiInjector annotation in the documentation. I am curious to understand its specific use and when it should be applied.
I am attaching the link to the documentation for reference:
https://sling.apache.org/documentation/bundles/models.html
¡Resuelto! Ir a solución.
Vistas
Respuestas
Total de me gusta
I found this old article(2022) from @Jörg_Hoh where there is a little explanation of OsgiInjector(I never used this one though)
https://cqdump.joerghoh.de/2022/11/28/sling-model-performance/
There is this cheat sheet from source code which is very useful AEM sling injector annotations which I usually use.
https://sourcedcode.com/blog/aem/aem-sling-model-injectors-annotations-cheat-sheet-reference-guide
Vistas
Respuestas
Total de me gusta
I found this old article(2022) from @Jörg_Hoh where there is a little explanation of OsgiInjector(I never used this one though)
https://cqdump.joerghoh.de/2022/11/28/sling-model-performance/
There is this cheat sheet from source code which is very useful AEM sling injector annotations which I usually use.
https://sourcedcode.com/blog/aem/aem-sling-model-injectors-annotations-cheat-sheet-reference-guide
Vistas
Respuestas
Total de me gusta
Hi @purushottam_kum , to my understanding we avoid @inject annotation because of its unpredictable behaviour and performance overhead.
So, instead of @inject it is recommended to use the @OSGiService
@OSGiInjector is conceptually similar to @inject or @OSGiService but with additional metadata i.e. it provides more granular control over how OSGi services are injected.
@OSGiInjector(name="log")
you can provide the name so that in case it can distinguish between the two services which implements the same interface.
@OsgiInjector(filter="paths=/bin/something")
private List<Servlet> servlets;
In this case, the filter paths=/bin/something likely matches services (e.g., Servlet implementations) registered in the OSGi registry with a property paths having the value /bin/something. List<Servlet> means that all matching services are injected as a list.
Vistas
Respuestas
Total de me gusta
It allows you to inject also OSGI services into your Sling Models.
Vistas
Respuestas
Total de me gusta
Vistas
me gusta
Respuestas
Vistas
me gusta
Respuestas