Expand my Community achievements bar.

Take care when reading content in the activate() method

Avatar

Employee Advisor

Reading data in the activate() method of your OSGI service is making your service unflexible. Whenever the content read in activate() changes, you have to restart the service/bundle/complete instance to make this updated content getting effective.

I blogged about it: Pattern: Configuration of OSGI services | Things on a content management system

5 Replies

Avatar

Level 10

Great post Jorg!! Good to know!!

Avatar

Community Advisor

Awesome post Jörg Hoh​ . Have faced same situation once .

Avatar

Community Advisor

Jörg Hoh

    What is your recommendation in reading configurations and assigning it in Activate method. I know it won't be a better solution , but just trying to understand. I saw the changes picked up in my local every time I add a new value to config node, but worried about PROD server.

Avatar

Employee Advisor

Do not mix that up with reading OSGI configuration, which is persisted in /apps/<myapp>/config/pid.of.my.service.xml; that's a different story and technically you are not reading it from the repository, but you are reading it from OSGI; and everything behind that is someone elses business :-)

I just wanted to say, do not use something like that:

because at that point, nothing happens when content at somepath changes.