Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

ConfigurationPlugin Start Ordering

Avatar

Level 1

I have registered a ConfigurationPlugin object in Bundle A to process and modify existing properties of configuration before they reach the Managed Service. Bundle A has no dependencies on other Bundles in the project as its sole purpose is to support ConfigAdmin.

 

https://docs.osgi.org/javadoc/r4v42/org/osgi/service/cm/ConfigurationPlugin.html

 

The problem here is that due to the OSGI nature of dynamics, another Bundle B as well as Configurator and ConfigAdmin starting very early, just before Bundle A, causing no plugin service being available to process its Configurations.

 

I want to ensure that plugin is known to the ConfigAdmin before any Configuration gets applied. 

 

It seems there is a solution by passing framework property named "felix.cm.config.plugins" with the config plugin id. However, I'm not sure how to pass or set the framework properties. I tried passing my ConfigurationPlugin through System Properties but it didn't seem to work.

java -jar aem-author-p4502.jar -Dsling.run.modes=author,local -Dfelix.cm.config.plugins=CustomConfigPluginPId

 

Any help to either set framework property correctly or prioritize starting Bundle A would be much appreciated.

 

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @ansrk0 

IMHO we usually shouldn't control service startup. In OSGi service start orders are not guaranteed and services may come and go at any time.

However, I found an article https://docs.osgi.org/javadoc/r4v43/core/org/osgi/framework/startlevel/package-summary.html where it says the OSGi bundle startlevels allow you to influence the start order for each bundle. You may try it.

Additionally found another article here https://www.datainmotion.de/osgi-configuration-admin-and-plugin-start-ordering/ but honestly not sure how can it be implemented in AEM.

Setting framework properties 

org.apache.felix.configadmin.plugin.interpolation

Try this "-Dorg.apache.felix.configadmin.plugin.interpolation"

Reference: https://github.com/apache/felix-dev/blob/master/configadmin-plugins/interpolation/README.md 

Hope that helps you!

Regards,
Santosh

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi @ansrk0 

IMHO we usually shouldn't control service startup. In OSGi service start orders are not guaranteed and services may come and go at any time.

However, I found an article https://docs.osgi.org/javadoc/r4v43/core/org/osgi/framework/startlevel/package-summary.html where it says the OSGi bundle startlevels allow you to influence the start order for each bundle. You may try it.

Additionally found another article here https://www.datainmotion.de/osgi-configuration-admin-and-plugin-start-ordering/ but honestly not sure how can it be implemented in AEM.

Setting framework properties 

org.apache.felix.configadmin.plugin.interpolation

Try this "-Dorg.apache.felix.configadmin.plugin.interpolation"

Reference: https://github.com/apache/felix-dev/blob/master/configadmin-plugins/interpolation/README.md 

Hope that helps you!

Regards,
Santosh