How to read different environment Config properties in you java code ?

naziyap131007

19-06-2019

Hi All,
I have been following Adobe Experience Manager Help | Reading Adobe Experience Manager OSGi Configuration Values  for reading properties in my code.
When i runt he sample provided it runs fine and gives correct output but when i integrate the same nodes and classes in my project, my service doesn't get registered on activation of bundle.

Since this sample uses the deprecated felix annotations i tried modifying it to current standards , now my service is registers but the activate method is never called.

I also saw one acs sample code on github SampleOsgiR6AnnotationsImpl.java but unable to understands if it is related to my requirement, since i dont see any connection with osgiConfig node.

What i need is able to read properties based on different run modes in my java file on bundle activation.
Can anyone please suggest for the same.

Accepted Solutions (1)

Accepted Solutions (1)

Jörg_Hoh

Employee

19-06-2019

The handling and injection of of OSGI properties, including the correct matching of runmodes should be left the framework. And from my point of view there is never a reason to bypass this. If you do, you are violating AEM best practices.

And if you really need to read the configuration for other environments (because otherwise the framework would it inject for you), something is wrong. Most likely you are using OSGI properties for a purpose they are not intended for.

Jörg