Expand my Community achievements bar.

Apache Sling Context Aware Configurations Override via OSGI Configuration

Avatar

Level 1

Hi, 
We are using OOTB ca-config "com.adobe.cq.wcm.core.components.config.HtmlPageItemsConfig" to load a script on our page.
But the script src is different for each environment. So, to override it through OSGI, I have tried using Apache Sling Context-Aware Configuration Override Provider: OSGi configuration. 
my Ca-config is stored as follows:

 

Screenshot 2024-11-26 at 13.33.53.png

Screenshot 2024-11-26 at 13.34.05.png

 I want override the "value" property of srcAttr and my Override provider config is as follows: 

Screenshot 2024-11-26 at 13.39.53.png

but I am unable to achieve it,
could someone help me what's need to be corrected in this case?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

5 Replies

Avatar

Community Advisor

Hi,

 

I think there’s some confusion, or perhaps I misunderstood your use case. If you need to switch a script per environment, you should use run modes and environment variables, as this is a more flexible and scalable approach. Context-Aware configurations are intended for multi-tenant projects within the same environment. Please check these threads:

 

https://stackoverflow.com/questions/57067256/how-do-i-use-run-modes-with-context-aware-configuration...

https://medium.com/@toimrank/aem-run-modes-4c36b9b0068e

https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/usi...

 

Hope this helps



Esteban Bustamante

Avatar

Level 1

Hi Esteban,

yes, I am aware of run modes, we are using ca-configs and few ca-configs have "src" values of which are run mode specific so I am trying to override the src of ca-configs through OSGI via Apache caconfig override provider.

Avatar

Level 1

Hi @arunpatidar,

Thanks for your response!
I have tried the way you have mentioned, syntax issue is solved but I am unable to override the property.
In general if you look at any ca-config, the properties are stored under jcr:content node, but for this config it is stored in the child resources present under jcr:node, this is causing some issue in identifying the property. is there a way to point the property for such configurations?