jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shaun Barriball" <sbarr...@yahoo.co.uk>
Subject RE: Providing RMI access for a model 2 - shared deployment
Date Thu, 15 Feb 2007 14:48:23 GMT
Hi Zukka,
Your idea worked perfectly. I created a custom servlet which registers a
repository in RMI after first locating it in the global JNDI. The servlet is
setup to register the repository with "//localhost:1099/jcr".

We can then access the repository remotely via the JCR command line tool (in
contribs) by:

1) amending the jndi.properties with

java.naming.factory.initial=com.sun.jndi.rmi.registry.RegistryContextFactory
java.naming.provider.url=rmi://localhost:1099

2) starting the command line tool (run.bat)

3) executing "jndi jcr"

This enables the application to run quickly as a Model 2 shared resource,
but allow administration via other utilities.

Regards,
Shaun.

PS> I'm happy to contribute the servlet code at some point if of use.


-----Original Message-----
From: Jukka Zitting [mailto:jukka.zitting@gmail.com] 
Sent: 15 February 2007 12:56
To: users@jackrabbit.apache.org
Subject: Re: Providing RMI access for a model 2 - shared deployment

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


		
___________________________________________________________ 
Copy addresses and emails from any email account to Yahoo! Mail - quick, easy and free. http://uk.docs.yahoo.com/trueswitch2.html

Mime
View raw message