S K C

Please Wait For Loading

AEM - Understanding the Sling Resolution Process! - Satish Kumar Choudhary - Tech Consultant Based out of New Jersey, USA

AEM – Understanding The Sling Resolution Process!

AEM – Understanding the Sling Resolution Process!

In this blog, I will explain how Sling maps URLs to a script or and servlet.

Scripts and servlets are itself resources in Sling and thus have a resource path: this is either the location in the JCR repository, the resource type in a servlet component configuration or the “virtual” bundle resource path (if a script is provided inside a bundle without being installed into the JCR repository).

Understanding Sling Resolution Process

  • Sling is resource oriented
  • Resources are maintained as Virtual tree
  • Resource is generally mapped to JCR node
URL ->Resource = JCR Structure

Basic Steps of Processing URL

Each Content item in JCR repository is exposed as an HTTP resource.
  1. Decompose the URL
  2. Search for respective Node
  3. Resolve the Resource
  4. Resolve Script/Servlet
  5. Create Rendering Chain
  6. Invoke Rendering Chain

Decomposing The URL

Lets take a sample url: http://learnaem.com/aem/slingresolution.printable.a4.html/a/b?x=true and try to decompose it. This URL can be decomposed as below:
  • http://learnaem.com – Protocol followed by Host name
  • aem/slingresolution – Content Path
  • .printable.a4 – Selector(s) – Alternate presentation
  • . html – Extension – Content Format

Lets take a sample url: http://learnaem.com/aem/slingresolution.printable.a4.html/a/b?x=true and try to decompose it.

This URL can be decomposed as below:

  • http://learnaem.com – Protocol followed by Host name
  • aem/slingresolution – Content Path
  • .printable.a4 – Selector(s) – Alternate presentation
  • . html – Extension – Content Format
  • a/b – Suffix – Additional information
  • x=true – Parameters – for dynamic content

Resolving Requests to Resources

  • Check if node exits at the location specified in the request
  • No node is found, search without file extension
  • If no node is found, return status code 404
  • If node is found, read node property to identify resource type and locate respective script to build the response
  • Respond with output

Locating and Rendering Scripts

Locate: 

Identify the resource from the request and locate its resource type, and extract the values

Render Default, if no matching Script:

If no matching script is found, default script is rendered

Multiple Match – More selector matches the better

The script name with best match is selected

e.g. http://learnaem.com/aem/slingresolution.print.a4.html

Locating and Rendering Scripts
Understanding the Sling Resolution Process Basic Steps of Processing Requests Decomposing the URL Resolving Requests to Resources Locating and Rendering Scripts Understanding URL decomposition
AEM – Understanding The Sling Resolution Process!

leave a comment