Sling started as an internal project at Day Software and taken up by Apache in September 2007. It’s the reason why some bundles/libraries are named like com.day.
The other important technologies include Apache Jackrabbit, Apache Felix, OSGi. We will discuss the Apache Sling in this article, and how to create a sample content and consume it.
Apache Sling is a web framework that uses a Java Content Repository (like Apache Jackrabbit) to store and manage content. Sling applications use either scripts or Java servlets to process HTTP requests in a RESTful way.
Sling in very simple terms could be described as a REST API for JCR. We can use http requests to manage content inside the repository. Sling provides a mechanism to render that content in different ways. We can use JSP, ESP scripts, Java (servlets, pojos, etc) in the Felix container to process requests and deliver content.
When a request is made for a particular node, Sling looks up for a property called sling:resourceType. This is used to look up the rendering scripts for the requested resource.
Apache Sling is:
- a REST-based web framework
- Content-driven, using JCR
- Powered by OSGi framework
- an Apache Open Source project
- Download Apache Sling Launchpad self-runnable jar from https://sling.apache.org/downloads.cgi. In my case, I have downloaded the latest jar org.apache.sling.launchpad-8.jar
- After the jar is downloaded, just start it as follows:java -jar org.apache.sling.launchpad-8.jar
- This starts the Sling embedded Web Server on port 8080 and writes application files into the sling folder found in the current working directory of your choice. You can check http://localhost:8080/system/console/bundles to see if the application is started properly or not. The credentials would be admin/admin. Here you would see different bundles in started state.
- Create content by giving the below cUrl command:
We can expect a response as below:
Now check the content by using the below URLs from a web browser.
Content node in HTML format: http://localhost:8080/content/myaemnode.html
The same node in JSON format: http://localhost:8080/content/myaemnode.json
No comments:
Post a Comment
If you have any doubts or questions, please let us know.