for people who are new to AEM how would anyone explain what is the difference between @AemObject and @SlingObject?
for e.g. :
public abstract class ComponentModel implements AemComponent {
@SlingObject // AND @AemObject
protected Resource resource;
}
my JUnit code which is like
ctx.currentResource("/content/location");
locationsModel = ctx.request().adaptTo(LocationsModel.class);
my JUnit code is working fine if I am using @SlingObject as annotation but not working if @AemObject is being used
please explain me the working of both
Thank you
Solved! Go to Solution.
Views
Replies
Total Likes
AEM Object: Injects common AEM objects that can be derived from a SlingHttpServletRequest. The injection is class-based, but may be supported by name hints when multiple targets are available for the same class.
Sling Object: Injects common Sling objects that can be derived from either a SlingHttpServletRequest, a ResourceResolver or a Resource. The injection is class-based.
For detailed description & differences, please go through :
https://wcm.io/sling/models/apidocs/io/wcm/sling/models/annotations/AemObject.html
AEM Object: Injects common AEM objects that can be derived from a SlingHttpServletRequest. The injection is class-based, but may be supported by name hints when multiple targets are available for the same class.
Sling Object: Injects common Sling objects that can be derived from either a SlingHttpServletRequest, a ResourceResolver or a Resource. The injection is class-based.
For detailed description & differences, please go through :
https://wcm.io/sling/models/apidocs/io/wcm/sling/models/annotations/AemObject.html