You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Chetan Mehrotra <ch...@gmail.com> on 2012/09/19 07:20:45 UTC
Improving Jackrabbit integration with OSGi Service Registry
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
Re: Improving Jackrabbit integration with OSGi Service Registry
Posted by Chetan Mehrotra <ch...@gmail.com>.
Created SLING-2624 [1] with a patch for proposed approach
Chetan Mehrotra
[1] https://issues.apache.org/jira/browse/SLING-2624
Re: Improving Jackrabbit integration with OSGi Service Registry
Posted by Chetan Mehrotra <ch...@gmail.com>.
> I haven't looked in detail, but IIUC what you're suggesting allows for
> injecting OSGi services in Jackrabbit instead of having to configure
> them in the repository.xml?
Yup
> If I'm correct, I agree that's useful. If that can be done in a
> backwards compatible way, I like the idea.
The proposed approach is backward compatible
> One issue might be the startup order of such things, would you need to
> guarantee that all such pluggable services are up before the
> repository starts, or is that handled cleanly?
Yes that too is handled. Currently it relies on Felix Dependency
Manager to coordinate repository startup order. If required it can be
managed via simple ServiceTracker implementation also. The startup
logic first uses BeanConfigVisitor to collect information about
services which need to be injected and then configures a
DependencyManager with those services as dependencies.
regards
Chetan
Re: Improving Jackrabbit integration with OSGi Service Registry
Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Chetan,
On Wed, Oct 3, 2012 at 11:08 AM, Chetan Mehrotra
<ch...@gmail.com> wrote:
> Is the proposal clear or some more details are required? Or its a
> solution looking for problem :)...
I haven't looked in detail, but IIUC what you're suggesting allows for
injecting OSGi services in Jackrabbit instead of having to configure
them in the repository.xml?
If I'm correct, I agree that's useful. If that can be done in a
backwards compatible way, I like the idea.
One issue might be the startup order of such things, would you need to
guarantee that all such pluggable services are up before the
repository starts, or is that handled cleanly?
-Bertrand
Re: Improving Jackrabbit integration with OSGi Service Registry
Posted by Chetan Mehrotra <ch...@gmail.com>.
Is the proposal clear or some more details are required? Or its a
solution looking for problem :)
Any comments/feedback would be helpful
Chetan Mehrotra