Sling Models provide the ability to use annotation driven, "pure" POJOs in Sling-based projects along with dependency injection capabilities and the ability to adapt various Sling objects OOTB.
Many Sling projects want to be able to create model objects - POJOs which are automatically mapped from Sling objects, typically resources, but also request objects. Sometimes these POJOs need OSGi services as well.
Sling Models provide these capabilities as well as basic dependency injection functionality.
The design goals include:
- Entirely annotation driven. "Pure" POJOs.
- Use of standard annotations where possible.
- Pluggability
- Ability to support resource properties (via
ValueMap
),SlingBindings
, OSGi services, request attributes OOTB - Ability to adapt multiple objects - minimal required
Resource
andSlingHttpServletRequest
- No need for the client to know/care that these objects are different than any other adapter factory
- Ability to support both classes and interfaces.
- Ability to work with existing Sling infrastructure (i.e. not require changes to other bundles).
The bundle is a part of the Apache Sling project (sling)
Further reading
- About Sling Models on the Apache Sling website
- A presentation introducing Sling Models capabilities in context of AEM, same slides from AEMHub 2014 conference