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 class loader. 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.
Leave a Reply