Create Custom OSGi Configuration In AEM

Mayur Satav
Nov 30, 2021
Create Custom OSGi Configuration In AEM by Mayur Satav

Open Service Gateway Initiative that is OSGi is a fundamental element in the technology stack of Adobe Experience Manager (AEM) which makes it modular. OSGi provides different configurations and also we can create our own custom configuration as per requirement.

Step 1 First of all create an interface whose public methods will represent the fields in our configuration.

How to create custom OSGi Configuration in AEM

Create an interface named CustomConfig.java under.\aem\core\src\main\java\com\demoproject\core\services\CustomConfig.java” and paste the following code into it.

Step 2 Now Create an implementation class CustomConfigImpl.java for our interface CustomConfig as below.

Step 3 Now create JSON file for the default values of our configuration. Create com.demoproject.core.services.impl.CustomConfigImpl.cfg.json” under.“\aem\ui.config\src\main\content\jcr_root\apps\demoproject\osgiconfig\config\”

How to create custom OSGi Configuration in AEM

create a similar JSON file under different environments like

  1. config.dev
  2. config.stage
  3. config.prod

and update the config values as per the environments.

--

--

Mayur Satav

Hello! welcome to my homepage! My name is Mayur Satav and I am a Senior Developer. I am an accomplished coder and programmer. Visit www.mayursatav.in