Expand my Community achievements bar.

SOLVED

OSGI Config

Avatar

Level 6

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

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@arvind ,

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

BrianKasingli_0-1625442037236.png

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-configurati...

 

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

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.

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

@arvind ,

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

BrianKasingli_0-1625442037236.png

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-configurati...

 

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

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.

Avatar

Community Advisor

Hi @arvind 

  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