jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Klimetschek <aklim...@day.com>
Subject Re: Jackrabbit JCR-RMI client sample code
Date Sat, 22 Aug 2009 09:48:20 GMT
On Sat, Aug 22, 2009 at 11:07 AM, kbar<whereiskent@gmail.com> wrote:
> ============================================
> Setting up the server part of the JCR-RMI layer is quite straightforward.
> After instantiating a local JCR repository you need to wrap it into a remote
> adapter and create an RMI binding for the repository. A variation of the
> following code is usually all that is needed in addition to the standard RMI
> setup (starting rmiregistry, etc.):
>
> Repository repository = ...; // The local repository
> String name = ...; // The RMI URL for the repository
>
> RemoteAdapterFactory factory = new ServerAdapterFactory();
> RemoteRepository remote = factory.getRemoteRepository(repository);
> Naming.bind(name, remote);  // Make the RMI binding using java.rmi.Naming
> ============================================
>
> Could someone explain what this all means in a bit more detail, perhaps with
> a java example file with all the right bits in there to actually talk to a
> remote repository?  I have no idea where this code should go or how to run
> it.  This looks like its meant to be on the server somewhere and somehow
> makes it able to be used via JCR-RMI.

Right, this is the server side. Where to put that code depends on your
type of server. In case of a standard servlet container, however,
things are much simpler as the jackrabbit-webapp component already
takes care of registering RMI, if configured. I'd recommend to start
with the standalone jar [1].

> But then I would also need an example
> client code to show me how to actually talk to it. I am sure its all very
> simple

Yes, it's simple, the sample code for the client is on the same page
directly below that, named "Accessing a remote repository" ;-) The RMI
URL will look something like rmi://localhost/jackrabbit.repository
(when using the standalone server).

See here [2] for more sample code by someone else on the list.

What you need for the client code to work is the jcr-1.0.jar (for the
JCR API) and the jackrabbit-jcr-rmi.jar.

[1] http://jackrabbit.apache.org/jackrabbit-standalone.html
[2] http://www.nabble.com/Getting-the-error-while-trying-to-access-the-repository-thru-jcr-RMI-concept-td23404753.html

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Mime
View raw message