OSGI Config | Community
Skip to main content
Level 5
July 4, 2021
Solved

OSGI Config

  • July 4, 2021
  • 2 replies
  • 894 views

Hi Team,

 

We are managing multilingual site. and need to manage different configuration values based on language site, meaning that we need one configuration per language site.

 

How we can manage to load specific configuration based on language or any property values inside configuration as input ?

 

Regards,

AP

 

 

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

@arvind-1 ,

for your scenario, I suggest using Apache Sling Context-Aware Configuration

The application needs different configuration for different sites, regions and tenants = different contexts. Some parameters may be shared, so inheritance for nested contexts and from global fallback values is supported as well. You have full control which content subtrees are the contexts in your application, the structure above is only an example.

Using the Context-Aware Configuration Java API you can get the matching configuration for each content resource without caring where it is stored or how the inheritance works.

full documentation can be found here: https://sling.apache.org/documentation/bundles/context-aware-configuration/context-aware-configuration.html

 

-------------------------------------------------------

However, if you really wanted to use OSGI configurations, then what you can do is to create your OSGI configuration with your language variations, for example:

  • eng.subscriptionApiKey
  • fr.subscriptionApiKey

And then using AEM backend, to detect the language from the SlingHttpServletRequest object, and either output eng.subscriptionApiKey or fr.subscriptionApiKey.

2 replies

BrianKasingli
Community Advisor and Adobe Champion
BrianKasingliCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
July 4, 2021

@arvind-1 ,

for your scenario, I suggest using Apache Sling Context-Aware Configuration

The application needs different configuration for different sites, regions and tenants = different contexts. Some parameters may be shared, so inheritance for nested contexts and from global fallback values is supported as well. You have full control which content subtrees are the contexts in your application, the structure above is only an example.

Using the Context-Aware Configuration Java API you can get the matching configuration for each content resource without caring where it is stored or how the inheritance works.

full documentation can be found here: https://sling.apache.org/documentation/bundles/context-aware-configuration/context-aware-configuration.html

 

-------------------------------------------------------

However, if you really wanted to use OSGI configurations, then what you can do is to create your OSGI configuration with your language variations, for example:

  • eng.subscriptionApiKey
  • fr.subscriptionApiKey

And then using AEM backend, to detect the language from the SlingHttpServletRequest object, and either output eng.subscriptionApiKey or fr.subscriptionApiKey.

Dipti_Chauhan
Community Advisor
Community Advisor
July 5, 2021

Hi @arvind-1 

  Agree with @briankasingli  .In your case there is no need to create OSGi for country level and language level .In your case configuration are based on content hierarchy. so you should go ahead with Context-Aware Configuration

 

Thanks

Dipti