An introduction to Sling, an open-source RESTful web framework that is part of Adobe Experience Manager’s underlying technology stack.
My name is Abhishek Dwevedi and in this video we are going to learn about Sling. After completing this video, you should be able to define Sling and should also be able to explain Sling content rendering process. Apache Sling is the framework for RESTful web-applications based on extensible content tree, like Java Content Repository AEM is built using Sling, it’s a web application framework, based on REST principles, that provide easy development of content-oriented application.
Sling uses a Java Content Repository, such as Apache Jackrabbit, or in the case of AEM, the CRX Content Repository as its data store. Some of the key principles of Apache Sling is it’s web application framework, which is designed for content-oriented application development, which provides RESTful web API to JCR based application.
So as AEM is a JCR based application, which has got CRX Content Repository. Sling can be used to fetch content from your repository. And it can provide that content to your user or to your code, which shall further provide that content to your user. Sling is resource-oriented. A resource represents a content object, and it’s maintained in a virtual tree. Most resources maps to a JCR node. Processing of the request is done by decomposing the URL and extracting the parts of the URL and then identifying a resource and further it is rendered through a script. We’ll see that process in more detail in upcoming slides.
So now let’s see how URL decomposition is done, and understand Apache Sling script resolution process. So as a step one, it identifies various informations in your URL. First it identifies the method it can be get or post. Then there is a path, which can usually be something like slash content and then paths to your page. Further there can be a selector which helps in selecting right script. Then there is an extension in which format you want to expose the content of the page. Further they can be suffix, and parameters. Now in the step one, the URL is decomposed in multiple parts. In step two, the content resolution process stops. Unlike JSPs, Sling doesn’t go and find the script first.
Instead Sling goes and finds the content first in your repository. So it will take the path, and it will go your, so it will take the path and go to your repository and identify if that path exists or not. And if that path exists, it will find a property called a sling resource type. So every content that you have in your repository will always have this information. So it will identify the path and it will go and find the resource type. Resource type is basically what kind of script should be run or what kind of component is going to make the page or render the page. So it will go to either abstract tree or reds-black tree, abstract tree has got a higher precedence. So first of all it will try to find an abstract tree, if it doesn’t find there then it will go to reds-black tree, and then it will try to find the script. Once it has got the script, it will further find the URL and check the selector. Based on the selector, it will identify the right script and then it will expose the content in the requested format that you have given. This graphic on your screen is called as Apache Sling cheat sheet. You can always refer to this whenever you are learning about content resolution process or when you are doing a debugging process in your AEM. Now you should be able to define Sling and should also be able to explain sling content rendering process. Thank you for watching this video, Have a great day. -