April 16, 2020
Estimated Post Reading Time ~

AEM OSGI Configuration and Implementation

The aim of this tutorial is to understand, How OSGi is configured in AEM . This is also a follow up question in many aem interviews that how osgi dependencies gets resolved , where osgi configurations are stored in aem.
In the starting, i too had curiosity to know, how osgi services interact with each other and how aem used osgi framework. Below i tried to provide a brief description about AEM OSGI configuration and Implementation.

After completing this tutorial. you will have a clear understanding of:
OSGI Framework Basics and Implementation in AEM
How Dependency is resolved in OSGI Bundle
How OSGI Bundles are Stored in AEM
Where OSGI Bundles are Stored in AEM

OSGI Framework Basics and Implementation in AEM:
OSGI also known as Open Service Gateway Initiative is built on the concept on bundles. Each Bundle has its own classloader. Which allows developers to start and stop each bundle separately.

The OSGI Framework consists of three major parts:- Bundles, Lifecycle, and Services.
Services layer exposes services objects that can be called from other services running in the OSGi server.
Life-cycle layer defines sequence of steps that the bundles should go through when installed, started, updated, stopped and uninstalled.
The Bundle layer is represented as a JAR file.


Now the question arises how the classes in bundle communicates with each other.

How Dependency is resolved in OSGI Bundle :
Each bundle has two parts component and its associated service. Services communicate with each other to access different components as shown in below diagram.


In Above example Class A of Bundle A has dependency on Class B & C of Bundle B & C , Now OSGI will export Class B & Class C and import them into Bundle A to resolve dependency.
How OSGI Bundles are Stored in AEM

All the bundles that we create in OSGI , can be found under <cq-quickstart folder>/launchpad/felix



When you click on any bundle, then you can see that each bundle is stored based on their versions.


When any bundle reaches to a maximum size, then it is zipped down to a tar file which can be found under <cq-quickstart folder>/repository/segmentstore.



Note: Tar file contains your data,bundles,versions and work-space backup.
Where OSGI Bundles are Stored in AEM

All the OSGI configurations are stored under (/apps/sling/config or /apps/system/config) by default. The configuration will be saved as a paragraph property jcr:data in binary(non-readable format) on respective node.


You can also view same configuration from Felix console http://localhost:4502/system/console/configMgr.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.