jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting" <jukka.zitt...@gmail.com>
Subject Re: Proposal for managing JCR resources in webapps
Date Sun, 03 Jun 2007 22:13:46 GMT

I've now implemented (see JCR-956 and the many related commits) a set
of servlets and other classes based on the ideas discussed earlier in
this thread.

The new code and fairly complete javadocs can be found in the
following packages:


To give a short overview of what's possible with these new classes,
here's how to instantiate a Jackrabbit repository with default
configuration and make it available in the application scope:


The org.apache.jackrabbit.commons.servlet.ServletRepository class can
be used to transparently access this repository (or any other
repository in application scope):

    public class MyServlet extends HttpServlet {
        private final Repository repository = new ServletRepository(this);

The ServletRepository class will automatically look up the actual
repository instance on demand from the servlet context and proxy any
method calls to it.

As a bonus feature, the repository servlet can be mapped to the URL
space to get easy access to repository descriptors:


For example the name of the repository vendor is then available as
text/plain via HTTP GET at

The instantiated repository can be made remotely accessible via RMI
with the following configuration:



The repository can then be accessed from a remote client using the
org.apache.jackrabbit.rmi.repository.URLRemoteRepository class:

    Repository repository = new

Replacing the RemoteBindingServlet class with RMIRemoteBindingServlet
or JNDIRemoteBindingServlet in the servlet configuration makes the
remote repository reference available also in an RMI registry or a
JNDI directory. Multiple such servlets can be configured in parallel
to make the remote reference available in multiple locations.

All the above options work just as well also with a non-local
repository instance. The JackrabbitRepositoryServlet configuration at
the beginning can be replaced for example with JNDIRepositoryServlet
or ContextRepositoryServlet from org.apache.jackrabbit.commons.servlet
to load the repository from JNDI or from another web application. Even
remote repositories can be used with servlets from

The default is to have the repository in the "javax.jcr.Repository"
servlet context attribute, but the attribute name can be configured in
each of the mentioned servlets for example to allow the use of
multiple different repositories in a single web application.

PS. I haven't yet tried to port jackrabbit-webapp to use these new
servlets and classes as I'm not sure how they could best made to work
with the dynamic configuration mechanism in use there.


Jukka Zitting

View raw message