Re: Replacing JRMP with JERI

Gregg Wonderly <[email protected]>
Newsgroups gmane.comp.java.sun.rmi
Message-ID <[email protected]>
NOTE: Sun is out on summer vacation this week, so they will not reply until next week most likely.

Robert DiFalco wrote:
> Are there any plans to split JERI out from Jini say into a net.jeri.*
> package?

I have not heard of anyone taking up this task.  It would require a JSR.  JERI technologies were originally submitted as
JSRs, but were rejected because of many reasons, some apparently political.  That was a good thing, because it caused
some more advancements to occur after things didn't have to me a JDK release schedule, I think.  There was some casual
discusion at JavaOne amongst some of the Jini Community members about doing this, but nothing is in the works that I
know of.

> Also, I was hoping for more of a step by step tutorial. Not so much on
> moving from Jini 1.0 to 2.0, more on just moving a regular old J2SE JRMP
> system to J2SE JERI. Anything like that around?

That article really points out exactly the issues that you need to deal with.  Specifically, you have remove all use of
UnicastRemoteObject.  When you do that, you can no longer rely on automatic stub replacement.  Instead, you have to keep
your exported proxy reference around, and pass it in cases that you are desiring remote access.  Then, you just need to
create an Exporter, export your object, and use it as you would otherwise.

BasicJeriExporter exp = new BasicJeriExporter(
        TcpServerEndPoint.getInstance(0),
        new BasicILFactory() );

is the basic exporter that most applications can use for simple TCP transport.

You typically want to use the net.jini.config packages features to allow you to change this at deployment, so you'd
probably create a file called jini.config with the following lines in it.

import net.jini.jeri.BasicILFactory;
import net.jini.jeri.tcp.TcpServerEndPoint;
import net.jini.jeri.export.BasicJeriExporter;

my.package.name.MyClass {
        private endpoint = TcpServerEndpoint.getInstance(0);
        private ilfactory = new BasicILFactory();
        exporter = new BasicJeriExporter( endpoint, ilfactory );
}

In your program, somewhere, you might do

        Configuration config = ConfigurationProvider.getInstance(
                new String[] { configFileName } );

or, you'd pass the configuration file on the command line and do

        public static void main( String args[] ) {
                Configuration config = ConfigurationProvider.getInstance( args );
                ...
        }

To get the exporter, you'd do

package my.package.name;

public class MyClass implements MyInterface {
        Configuration config;
        MyInterface exported;

        ...

        public void setup( ... ) throws ConfigurationException {
                Exporter exp = (Exporter)config.getEntry( getClass().getName(),
                        "exporter", Exporter.class );
                exported = (MyInteface)exp.export(this);
        }
}

That's pretty much all that is needed to get started.  The most wide spread change is the removal of stub replacement.
This can be recreated in one of two ways.  You can set the jeri property that turns this back on (look at the jini-users
archives for recent discussion of this issue), or you can provide a writeReplace() implementation that sends out the
exported object instead of the local object.

Again, John's follow on articles do talk about many of these issues.  Jini is just some cool tools that use the RMI
programming model for solving distributed computing problems.  JERI is RMI version 2.0.  There are of course lots of
issues that might be important to you.  If you can share the basic architecture of your application, or any other
concerns that you have, I'll try and answer your questions.  If I can't, then I think that Peter should be back in here
next week to help out if needed.

Gregg Wonderly

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff RMI-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

For a list of frequently asked RMI questions please refer to:
http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html

To view past RMI-USERS postings, please see:
http://archives.java.sun.com/archives/rmi-users.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.