You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by kbar <wh...@gmail.com> on 2009/08/22 11:07:04 UTC

Jackrabbit JCR-RMI client sample code

I would like to remotely access a jackrabbit repository but can't find any
example code on how to do this. I have read through the following page 

http://jackrabbit.apache.org/jackrabbit-jcr-rmi.html

which states the following

============================================
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. 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, I am just new to Java since I am coming from 10 years of C++ and C#.

I started writing my own server application that could stream files from
jackrabbit to a client machine when I found out about JCR-RMI and I think I
should be to everything I need, if only I had some example files that tells
me how to do it.

Once I have my head around how this all fits together I might put a site
together myself that has a lot of useful code snippets to help other
developers get started with Jackrabbit as well. 

Thanks,
Kent





-- 
View this message in context: http://www.nabble.com/Jackrabbit-JCR-RMI-client-sample-code-tp25091962p25091962.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: Jackrabbit JCR-RMI client sample code

Posted by Guo Du <mr...@gmail.com>.
On Sat, Aug 22, 2009 at 10:07 AM, kbar<wh...@gmail.com> wrote:
> client code to show me how to actually talk to it. I am sure its all very
> simple, I am just new to Java since I am coming from 10 years of C++ and C#.

Java/RMI just one way to access remote repository, you may using REST
api to access repository which supported by Sling
http://sling.apache.org

--Guo

Re: Jackrabbit JCR-RMI client sample code

Posted by Alexander Klimetschek <ak...@day.com>.
On Sat, Aug 22, 2009 at 11:07 AM, kbar<wh...@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