Sling API vs JCR API | Adobe Higher Education
Skip to main content
Level 3
February 16, 2023

Sling API vs JCR API

  • February 16, 2023
  • 3 の返信
  • 5781 ビュー

AEM supports the use of both Sling APIs and JCR APIs. 

 

The docs mention "While the JCR is AEM’s content repository, its APIs are NOT the preferred method for interacting with the content. Instead prefer the AEM APIs (Page, Assets, Tag, and so on) or Sling Resource APIs as they provide better abstractions." 

 

Furthermore, "Broad use of JCR APIs’ Session and Node interfaces in an AEM application is code-smell. Ensure Sling APIs should be used instead."

 

Personally, I used the JCR API for creating nodes and properties in custom workflows.

And found it necessary to use the JCR API in the unit tests.

 

Did you personally come across any use cases where the JCR API is better than the sling API? 

And is it always a legitimate code smell? 

このトピックへの返信は締め切られました。

3 の返信

Adobe Employee
February 16, 2023
arunpatidar
Community Advisor
Community Advisor
February 16, 2023

I can se only one use case when JCR api is better then Sling API

It is when you write Event on nodetype, which sling does not supports.

 

Always use Framework API first (AEM <-- Sling <--- JCR)

Arun Patidar
BrianKasingli
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
February 16, 2023

I agree.

Manu_Mathew_
Community Advisor
Community Advisor
February 17, 2023
joerghoh
Adobe Employee
Adobe Employee
February 18, 2023

Oh well, we are constantly trying to reduce the slack in Sling 🙂 and make its performance on par with JCR; of course it's always a bit of overhead, but Sling offers some nice features which JCR cannot do; mostly because it's a fixed API we cannot extend anymore.