Expand my Community achievements bar.

SOLVED

sling context in bundles

Avatar

Level 1

Hi, I am not an expert in osgi, just learning the ropes. So apologies if I use the wrong terminology, hope you can help.

I have a service that runs within the OSGI framework and a scheduler that triggers that service to do something on a regular basis.

That service is never called from a CQ component, so I cannot pass it parameters that are read from the JCR. Yet I want to provide it values that are stored in the JCR. How could I achieve this? Can I look up a node in the JCR from any service / bundle? How would I do this?

The example I give is in fact a configuration service that stores key value pairs. Another bundle reads from this configuration service. Now I want to store the values in the JCR (so that my authors can update them easily).

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

You can always store OSGi configurations for your service within the repository, for example the scheduler expression for your OSGi component could be stored as property within a sling:OsgiConfig node. The neat thing about this is it gives you the added flexibility of different configurations for different environments (author vs publish, dev vs prod...).  http://dev.day.com/docs/en/cq/current/deploying/configuring_osgi.html#OSGi Configuration in the Repository

Also you can always add a reference to the ResourceResolverFactory and get an instance of a ResourceResolver which can return a resource based on a given path in the repository (which can be adapted to a Node or ValueMap). The ResourceResolver can also be adapted to the Session interface or PageManager interface...

View solution in original post

2 Replies

Avatar

Correct answer by
Employee Advisor

You can always store OSGi configurations for your service within the repository, for example the scheduler expression for your OSGi component could be stored as property within a sling:OsgiConfig node. The neat thing about this is it gives you the added flexibility of different configurations for different environments (author vs publish, dev vs prod...).  http://dev.day.com/docs/en/cq/current/deploying/configuring_osgi.html#OSGi Configuration in the Repository

Also you can always add a reference to the ResourceResolverFactory and get an instance of a ResourceResolver which can return a resource based on a given path in the repository (which can be adapted to a Node or ValueMap). The ResourceResolver can also be adapted to the Session interface or PageManager interface...

Avatar

Level 2

A good example of accessing the repository from a bundle can be found in:http://helpx.adobe.com/adobe-cq/using/persisting-cq-data-java-content.html 

Hope this is the information what you are after.