Current Sling integration with Jackrabbit (JR) allows for simpler access to Repository services from other bundles via the OSGi Service Registry (SR). However to make use of OSGi services within JR is tricky. Some integration is done wrt security but for other areas one needs to use fragments.
To simplify such integration recently a new feature was added to JR (JCR-3420) [1] which allows for registering a custom BeanFactory with JR. This would allow usage of services from service registry within JR. Sample Usage ============ To demonstrate the use of such a feature I took the usecase of externalizing the AuthorizableAction [2] in Sling env. So it should be possible to use an OSGi service which implements the AuthorizableAction within JR. An implementation of that is available at [3]. In the JR repository.xml we would have an entry like show below <AuthorizableAction class="org.apache.jackrabbit.core.security.user.action.AuthorizableAction" /> Then in Sling side we provide an OsgiBeanFactory which is passed to JR through ConfigurationParser. This factory would internally lookup the service and provide it to JR. It can also ensure that Repository service is restarted if the service is not available. A proper implementation of AuthorizableAction should be able to multiplex the calls and allow for dispatching classbacks to multiple registered action classes found in SR Another implementation [4] would make this BeanFactory implementation generic. In such a case if any class configured in repository.xml of type interface (rather than actual implementation class) would be provided via services from SR and by monitioring the service events we can ensure that repository is started/stooped properly. Other areas it can be used is like in providing custom DataStore say which uses Amazon S3 as a backend. It would be much simpler to provide such an implementation as an OSGi Service as then it can make use of other features like ConfigAdmin, Extension points, Thread pooling. In current mode we would need to package it as a fragment and then its very hard to make use of various OSGi features. Would such a feature be useful in Sling. Thoughts? Chetan Mehrotra [1] https://issues.apache.org/jira/browse/JCR-3420 [2] http://jackrabbit.apache.org/api/2.4/org/apache/jackrabbit/core/security/user/action/AuthorizableAction.html [3] https://github.com/chetanmeh/sling/compare/osgi-factory [4] https://github.com/chetanmeh/sling/compare/osgi-factory-adv#L1R134
