AEM osgiconfig node for different profile.

vimla_s

31-05-2019

Hi Team,

As I have three Instances for aem one is author , publish and development, For this I have created three folders like config.author, config.publish and config.development and created three sling:osgiConfig node with the same name but multiple copies in each of the folder,

And now with the help of data-sly-use  I am able to use the node properties.

But the problem here is in data-sly-use i Have to give the complete path of the node which included config.author and so.

I have diff configuration for diff env for which i have to change the path in every env.

Please let me know how to use relative path and value of those propeties in my HTML.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Jörg_Hoh

Employee

03-06-2019

You should never OSGI configuration explicitly, but you should let the container do this for you!


From what I understood you have these nodes:

* /apps/myapp/config.author/x.y.z (sling:osgiConfig)

* /apps/myapp/config.publish/x.y.z (sling:osgiConfig)

* /apps/myapp/config.development/x.y.z (sling:osgiConfig)

which is correct. Now you need to have a service with the PID x.y.z, which can be done the easiest way, if you "x.y" is the java package name and "z" is the classname of that service. Now you can read the configuration value as part of the service activation.

And as the next part you need to create a slingmodel, which is using your x.y.z service to do something useful, and embed that slingmodel into HTL.

This might sound overkill, but if it's really overkill, you are often trying to store parameters as OSGI configuration, which should not be OSGI configs at all.

HTH,

Jörg