Apache Sling Context Aware Configurations Override via OSGI Configuration | Community
Skip to main content
November 26, 2024
Solved

Apache Sling Context Aware Configurations Override via OSGI Configuration

  • November 26, 2024
  • 2 replies
  • 1199 views

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:

 

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

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
November 26, 2024

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-configurations-in-aem

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

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

 

Hope this helps

Esteban Bustamante
RahulGa6Author
November 29, 2024

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.

arunpatidar
Community Advisor
Community Advisor
November 26, 2024
RahulGa6Author
November 29, 2024

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?

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
November 29, 2024