Expand my Community achievements bar.

SOLVED

Node creation

Avatar

Level 4

By using session(jcr api) or resource(sling api) we can create node , is any difference in between them?

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@user96222 

In Adobe Experience Manager (AEM), both JCR (Java Content Repository) API and Sling API are commonly used for content manipulation. Here's a brief overview of the two and their differences:

  1. JCR API (Java Content Repository API):

    • JCR API is a standard Java API for accessing and manipulating content stored in a JCR-compliant repository, which is the case with AEM.
    • It provides a low-level API for CRUD (Create, Read, Update, Delete) operations on content nodes and properties.
    • When using the JCR API, you typically work directly with the javax.jcr.Session object to perform operations such as creating nodes, setting properties, and saving changes to the repository.
  2. Sling API:

    • Sling is an Apache framework that provides a higher-level abstraction over the JCR API and other functionalities in AEM.
    • Sling API simplifies the development of web applications in AEM by providing resource-oriented abstraction, request handling, and URL mapping.
    • Sling API abstracts away the complexities of JCR API and provides additional features such as resource resolution, servlet resolution, request processing, and more.
    • When using the Sling API, you typically work with org.apache.sling.api.resource.ResourceResolver to interact with resources (nodes) in the AEM repository.

Differences:

  • Abstraction Level: JCR API operates at a lower level, providing direct access to the content repository, while Sling API operates at a higher level, providing abstractions over resources and request handling.
  • Ease of Use: Sling API tends to be more developer-friendly and easier to use for common tasks like resource manipulation, request handling, and servlet resolution.
  • Additional Features: Sling API provides additional features beyond basic CRUD operations, such as resource resolution, request processing, servlet resolution, etc.
  • Performance: Direct usage of JCR API might offer slightly better performance in certain scenarios since it operates at a lower level, but the difference is usually negligible.

In summary, while both JCR API and Sling API can be used to create nodes in AEM, they operate at different levels of abstraction and offer different features and benefits. The choice between them depends on the specific requirements of your application and your preference for abstraction level and ease of use

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

@user96222 

In Adobe Experience Manager (AEM), both JCR (Java Content Repository) API and Sling API are commonly used for content manipulation. Here's a brief overview of the two and their differences:

  1. JCR API (Java Content Repository API):

    • JCR API is a standard Java API for accessing and manipulating content stored in a JCR-compliant repository, which is the case with AEM.
    • It provides a low-level API for CRUD (Create, Read, Update, Delete) operations on content nodes and properties.
    • When using the JCR API, you typically work directly with the javax.jcr.Session object to perform operations such as creating nodes, setting properties, and saving changes to the repository.
  2. Sling API:

    • Sling is an Apache framework that provides a higher-level abstraction over the JCR API and other functionalities in AEM.
    • Sling API simplifies the development of web applications in AEM by providing resource-oriented abstraction, request handling, and URL mapping.
    • Sling API abstracts away the complexities of JCR API and provides additional features such as resource resolution, servlet resolution, request processing, and more.
    • When using the Sling API, you typically work with org.apache.sling.api.resource.ResourceResolver to interact with resources (nodes) in the AEM repository.

Differences:

  • Abstraction Level: JCR API operates at a lower level, providing direct access to the content repository, while Sling API operates at a higher level, providing abstractions over resources and request handling.
  • Ease of Use: Sling API tends to be more developer-friendly and easier to use for common tasks like resource manipulation, request handling, and servlet resolution.
  • Additional Features: Sling API provides additional features beyond basic CRUD operations, such as resource resolution, request processing, servlet resolution, etc.
  • Performance: Direct usage of JCR API might offer slightly better performance in certain scenarios since it operates at a lower level, but the difference is usually negligible.

In summary, while both JCR API and Sling API can be used to create nodes in AEM, they operate at different levels of abstraction and offer different features and benefits. The choice between them depends on the specific requirements of your application and your preference for abstraction level and ease of use