+1 using @Inject is not only a performance problem, it also may lead to unexpected results if an injector steps in you are not aware of.
stefan > -----Original Message----- > From: Jörg Hoh <jhoh...@googlemail.com.INVALID> > Sent: Thursday, December 8, 2022 10:25 AM > To: Sling Developers List <dev@sling.apache.org> > Subject: [Sling Models documentation] discourage the use of @Inject > > Hi, > > currently the the Sling Models documentation is a bit confusing; the > examples show only the use of the "@Inject" annotation, while more down > (at > [1]) in an not obvious location the use of @Inject is discouraged. > Also, when I benchmarked the use of Sling Models with different > annotations [2] I found that in some situations @Inject can have a huge > performance penalty compared to the injector-specfic annotations, so I > would also argue from this perspective, that we should heavily discourage > the use of @Inject. > > But at the top we state as one of the design goals of Sling Models to use > standard annotations (which are mostly discouraged at [1] in favor of > custom annotations). > > In the context of SLING-11711 I plan to rework the documentaiton and all > examples to use injector-specific annotations, remove the design goal of > standard annotations, and mention the discouraged annotations only in a > separate section as discouraged (not deprecated!). > > WDYT? > > Jörg > > > [0] https://sling.apache.org/documentation/bundles/models.html > [1] https://sling.apache.org/documentation/bundles/models.html#hints-1 > [2] https://cqdump.joerghoh.de/2022/11/28/sling-model-performance/ > [3] https://issues.apache.org/jira/browse/SLING-11711 > -- > Cheers, > Jörg Hoh, > > https://cqdump.joerghoh.de > Twitter: @joerghoh