What is the purpose behind building of Apache Sling, Felix, Jackrabbit projects

╄→尐↘猪︶ㄣ 提交于 2019-11-30 04:49:32

The combination of Apache Jackrabbit, Apache Sling, and Apache Felix allows you to build web application.

Apache Jackrabbit is the reference implementation of the JCR API. The JCR API is to manage content repositories; to manage, for example, web content. A content repository is a mix between file system and a database.

The JCR API is specially made to deal with web content. Why use the JCR API, and why not use a relational database API? URLs are hierarchical, as in a file system. Relational databases don't easily support hierarchical access. Why not use a file system API? Because the JCR supports transactions, versioning, and a lot of other features that file system APIs don't support.

Apache Sling is a web framework based on the JCR API, and taking advantage of the features provided by the JCR API (15 Minute introduction).

Apache Felix is an OSGi container. It allows to seamlessly start, stop, and replace components of a web application (jar files, in a sense), while the web server is running. That means it allows you to change the application without having to restart the server.

santiagozky

Sling in very simple terms could be described as a REST API for JCR. you can use http requests to manage content inside the repository.

Additionally, Sling provides a mechanism to render that content in different ways for web consumption. you can use scripts (JSP for example) and the java code (servlets, pojos, etc) in the Felix container to process requests and deliver a request.

When a request is made for a particular node, Sling looks up for a property called sling:resourceType, this is a lookup key for rendering scripts. Then the appropiate script is executed using the node as input.

You could write different kinds for renderers and then use it to display your content in different ways.

For example, you could write two scripts full.json.jsp and short.json.jsp and then use them to render the same node in two different ways:

/content/app/node.full.json 

OR

/content/app/node.short.json.

Sling basically matches tokens in the request URL to select an appropriate script.

They have a really nice cheat sheet that explains how request resolution and rendering works

it is a bit more complex than this, since everything is organized in resources and components. you want to check their site for more info

I had the same doubts. The best response I was able to find is in the official Sling page (https://sling.apache.org/)


(What is) Apache Sling, in a hundred words:

Apache Sling is a web framework that uses a Java Content Repository, such as Apache Jackrabbit, to store and manage content.

Sling applications use either scripts or Java servlets, selected based on simple name conventions, to process HTTP requests in a RESTful way.

The embedded Apache Felix OSGi framework and console provide a dynamic runtime environment, where code and content bundles can be loaded, unloaded and reconfigured at runtime.


So, resuming it:

  • Sling is a web framework --> using jackrabbit --> based/supported on JCR API.
  • You can see Apache Felix like a container with its manager.

Note that Sling started as an internal project at Day Software. It's the reason why some bundles/libraries are named like com.day, but in the ends they are two names for the same.

Also, if you want to be clear about Jackrabbit and JCR API you can visit the Jackrabbit's official page http://jackrabbit.apache.org/jcr/jackrabbit-architecture.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!