Posts

Showing posts from August, 2023

@Inject : A discouraged sling-model annotation

Image
"I just copy and paste it from somewhere and since it was working so I keep it like this. 😎"           @ Model (adaptables = Resource . class )      public class ExampleModel { @ Inject private MyService myService ; @ Inject private String title ; // ... rest of the class } I got this reply from the developer while reviewing his code above so thought of writing one extension post of my previous blog  Common Myths Around Sling Model .  So lets dive into the working mechanism of @Inject annotation but before that I would like to explain the injector first.                                                                      An OOB injector      @ Component (property= Constants . SERVICE_RANKING + ":Integer=3000" ,                service={ Injector . class , InjectAnnotationProcessorFactory2 . class }) public class ChildResourceInjector extends AbstractInjector implements Injector ,      Inject