AEM osgiconfig node for different profile.

Avatar

Avatar

vimla_s

Avatar

vimla_s

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)

Avatar

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

991

Correct Reply

1.0K

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

991

Correct Reply

1.0K
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

Answers (3)

Answers (3)

Avatar

Avatar

Mayank_Gandhi

Employee

Avatar

Mayank_Gandhi

Employee

Mayank_Gandhi
Employee

03-06-2019

kautuksahni​ Can you please move the thread to AEM.

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

3.0K

Likes

1.1K

Correct Reply

859

Avatar

Arun_Patidar

MVP

Total Posts

3.0K

Likes

1.1K

Correct Reply

859
Arun_Patidar
MVP

03-06-2019

use java api to read config.

Example :

aem63app-repo/GetFactoryConfigServlet.java at master · arunpatidar02/aem63app-repo · GitHub

If config is not factory you can use pid filter, example

private static final String filter = "(service.pid=com.abc.xxx.abc.def)";

Avatar

Avatar

kautuk_sahni

Community Manager

Total Posts

5.8K

Likes

1.0K

Correct Reply

1.1K

Avatar

kautuk_sahni

Community Manager

Total Posts

5.8K

Likes

1.0K

Correct Reply

1.1K
kautuk_sahni
Community Manager

03-06-2019

Done, thanks.