Sunday, 17 March 2024

Java APIs in AEM

Java™ API Best Practices

Adobe Experience Manager (AEM) is built on a rich open-source software stack that exposes many Java™ APIs for use during development. This article explores the major APIs and when and why they should be used.

AEM is built on four primary Java™ API sets.

  • Adobe Experience Manager (AEM)

    • Product abstractions such as pages, assets, workflows, etc.
  • Apache Sling Web Framework

    • REST and resource-based abstractions such as resources, value maps, and HTTP requests.
  • JCR (Apache Jackrabbit Oak)

    • Data and content abstractions such as node, properties, and sessions.
  • OSGi (Apache Felix)

    • OSGi application container abstractions such as services and (OSGi) components.

The general rule is to prefer the APIs/abstractions the following order:

  1. AEM
  2. Sling
  3. JCR
  4. OSGi

AEM APIs

AEM APIs provide abstractions and functionality specific to productized use cases.

For example, AEM’s PageManager and Page APIs provide abstractions for cq:Page nodes in AEM that represent web pages.

While these nodes are available via Sling APIs as Resources, and JCR APIs as Nodes, AEM’s APIs provide abstractions for common use cases. Using the AEM APIs ensures consistent behavior between AEM the product, and customizations and extensions to AEM.

  1. com.adobe.cq - supports product use cases
  2. com.adobe.granite - cross-product platform use-cases, such as workflow or tasks (which are used across products: AEM Assets, Sites, and so on)
  3. com.day.cq - contains “original” APIs. These APIs address core abstractions and functionalities that existed before and/or around Adobe’s acquisition of Day CQ.
Query APIs
AEM supports multiple query languages. The three main languages are 
XPath, and 

Sling APIs
Apache Sling is the RESTful web framework that underpins AEM. Sling provides HTTP request routing, models JCR nodes as resources, provides security context, and much more.

JCR APIs

The JCR (Java™ Content Repository) 2.0 APIs is part of a specification for JCR implementations (in the case of AEM, Apache Jackrabbit Oak). All JCR implementation must conform to and implement these APIs, and thus, is the lowest level API for interacting with AEM’s content.

Always prefer the JCR APIs over the Apache Jackrabbit Oak APIs. The JCR APIs are for interacting with a JCR repository, whereas the Oak APIs are for implementing a JCR repository.

No comments:

Post a Comment

Dispatcher configurations in AEM - 2

 Dispatcher configuration 1. The Dispatcher configuration is stored in the dispatcher.any text file. 2. The file contains a series of single...