jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting" <jukka.zitt...@gmail.com>
Subject Re: Providing RMI access for a model 2 - shared deployment
Date Thu, 15 Feb 2007 12:55:45 GMT
Hi,

On 2/15/07, Shaun Barriball <sbarriba@yahoo.co.uk> wrote:
> * However I expected/hoped that specifying an rmi-url with host and port
> would result in the repository being exposed via RMI. This didn't happen.
>
> Looking at the code for RepositoryAccessServlet it does not appear to be
> capable of exposing a repository via RMI, unlike RepositoryStartup which
> can. I'm guessing RepositoryAccessServlet  is only intended for access, not
> for publishing?

Ah, you're right, my mistake.

> If this is the case, is it possible to get the RepositoryStartup to either:
>
>  * read from a JNDI name and publish via RMI, or
>
>  * initialise the repository and publish into the global JNDI spec for other
> webapps AND via RMI. Perhaps I'm just looking for the right combination of
> "java.naming.provider.url" and "java.naming.factory.initial" values to
> emulate the settings on the Tomcat server.xml.

The RepositoryStartup servlet always starts up the repository locally,
but you can instruct it to register the repository both in JNDI and
RMI as in your second option above. Unfortunately I don't think that
Tomcat allows a webapp to modify the global JNDI tree, so you'd need
to use some other JNDI implementation.

An alternative approach would be to create a custom servlet class that
looks up the repository from JNDI and binds it in RMI directly.
Something like this:

    InitialContext context = new InitialContext();
    Context environment = (Context) context.lookup("java:comp/env");
    Repository repository = (Repository) environment.lookup("...");

    RemoteAdapterFactory factory = new ServerAdapterFactory();
    RemoteRepository remote = factory.getRemoteRepository(repository);
    Naming.bind("...", remote);

Just remember to keep a local reference to the remote repository
adapter within the servlet instance to avoid it from being garbage
collected when no clients are connected.

BR,

Jukka Zitting

Mime
View raw message