Andreas Schaefer Sr. wrote > Hi > > I would like to listen to JCR Nodes being added, modified and removed in > Sling and saw that you provide the Resource Change Listener > which would work perfectly but I could not figure out how to make the paths > to listen for dynamic. > > What I would love to have is to configure an OSGi Service that either > implements ResourceChangeListener or does register one with Sling. > The paths to listen for are set by the OSGi Configuration and the user can add, change or remove paths. > > Is there a way to create a Resource Change Listener(s) dynamically so that > when I receive the configuration (changes) I can register > them rather when the Resource Change Listener service is deployed? > If you are using Declarative Services to implement your ResourceChangeListener you can do a couple of things. Simply use the org.osgi.service.component.annotations.* annotations:
- by using @Component(configurationPolicy=ConfigurationPolicy.REQUIRE), your component only gets active if there is an OSGi configuration - you can now configure the paths through such an OSGi configuration. - In order to make the paths property for the listener configurable though the configuration, the easiest is to use @Component(configurationPolicy=ConfigurationPolicy.REQUIRE, property="resource.paths=/") - if now someone registers an OSGi configuration with a value for resource.paths property (being either a string or string array), then your listener will listen for those paths - if the OSGi configuration is changed, your listener will be udpated. Carsten -- Carsten Ziegeler Adobe Research Switzerland cziege...@apache.org