AEM is built using Sling, a Web application framework based on REST principles that provides easy development of content-oriented applications. Sling uses a JCR repository, such as Apache Jackrabbit, or in the case of AEM, the CRX Content Repository, as its data store.

Apache Sling in five bullets points.
  • REST based web framework.
  • Content-driven, using a JCR content repository.
  • Powered by OSGi
  • Scripting inside, multiple languages (JSP, server-side javascript, Scala, etc.)
  • Apache Open Source project

For more information click here

Interview Questions

Note: To build an application using Apache Sling watch this video

REST (Representational State Transfer) architectural style describes six constraints applied to architecture:

  • Uniform Interface – Individual resources are identified using URLS. The resources (database) are themselves different from the representation (XML, JSON, HTML) sent to the client. The client can manipulate the resource through the representations provided they have the permissions. Each message sent between the client and the server is self-descriptive and includes enough information to describe how it is to be processed. The hypermedia that is hyperlinks and hypertext act as the engine for state transfer.
  • Stateless Interactions – none of the clients context is to be stored on the server side between the request. All of the information necessary to service the request is contained in the URL, query parameters, body or headers.
  • Cacheable – Clients can cache the responses. The responses must define themselves as cacheable or not to prevent the client from sending the inappropriate data in response to further requests.
  • Client-Server – The clients and the server are separated from each other thus the client is not concerned with the data storage thus the portability of the client code is improved while on the server side the server is not concerned with the client interference thus the server is simpler and easy to scale..
  • Layered System – At any time client cannot tell if it is connected to the end server or to an intermediate. The intermediate layer helps to enforce the security policies and improve the system scalability by enabling load-balancing.
  • Code on Demand – an optional constraint where the server temporarily extends the functionality of a client by the transfer of executable code.
SOAP is a protocol REST is an architectural style
SOAP stands for Simple Object Access Protocol. REST stands for Representational State Transfer.
SOAP uses services interfaces to expose the business logic. REST uses URI to expose business logic.
SOAP defines its own security. RESTful web services inherits security measures from the underlying transport.
SOAP permits XML data format only. REST permits different data format such as Plain text, HTML, XML, JSON etc.

The following diagram explains Sling script resolution: it shows how to get from HTTP request to content node, from content node to resource type, from resource type to script and what scripting variables are available.


For more information watch this video

A Sling Model is implemented as an OSGi bundle. A Java class located in the OSGi bundle is annotated with @Model and the adaptable class (for example, @Model(adaptables = Resource.class). The data members (Fields) use @Inject annotations. These data members map to node properties.

Example of sling model :
  import javax.inject.Inject;
 @Model(adaptables = Resource.class)
   public class UserInfo {
   private String firstName;
    private String lastName;
  private String technology;
  public String getFirstName() {
    return firstName;
public String getLastName() {
return lastName;
public String getTechnology() {
return technology;

For more information

For more information

For more information watch this video

Sling is content-centric. This means that processing is focused on the content as each (HTTP) request is mapped onto content in the form of a JCR resource (a repository node):

  • the first target is the resource (JCR node) holding the content
  • secondly, the representation, or script, is located from the resource properties in combination with certain parts of the request (e.g. selectors and/or the extension)

Due to the content-centric philosophy, Sling implements a REST-oriented server and thus features a new concept in web application frameworks. The advantages are:

  • very RESTful, not just on the surface; resources and representations are correctly modelled inside the server
  • removes one or more data models
    • previously the following were needed: URL structure, business objects, DB schema;
    • his is now reduced to: URL = resource = JCR structure

These are the api and classes frequently used in AEM

  • ValueMap - The ValueMap is an easy way to access properties of a resource.
  • ResourceResolver - The ResourceResolver defines the service API which may be used to resolve Resource objects.
  • ResourceProvider - API for providers of resources.
  • Resource - Resources are pieces of content on which Sling acts The Resource is also an Adaptable to get adapters to other types.
  • ResourceWrapper - The ResourceWrapper is a wrapper for any Resource delegating all method calls to the wrapped resource by default.
  • ResourceUtil - The ResourceUtil class provides helper methods dealing with resources.

For more information click here

Sling JCR Installer scans the CRX repository for artifacts and provides them to the OSGi installer