sling context in bundles | Community
Skip to main content
October 16, 2015
Solved

sling context in bundles

  • October 16, 2015
  • 2 replies
  • 1004 views

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).

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Daniel_Gordon

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...

2 replies

Daniel_Gordon
Adobe Employee
Daniel_GordonAdobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

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...

Adobe Employee
October 16, 2015

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.