Here I provide a sample registry and its interfaces, as well as testing programs. You can use a different registry: however, if you are using the defintion of remote object reference (ROR) as provided, this registry will be useful for you. These programs also offer examples of programs for socket-based servers.
First of all, note that I have denoted the IP address part of an ROR as a string, rather than as an INetAddress. This is more natural.
There are five programs here. I provide all in the source form.
SimpleRegistryServer.java
SimpleRegistry.java
LocateSimpleRegistry.java
testRebind.java
testLookup.java
I have also supplied:
which is necessary for compilation.
To start the simple registry server, provide one argument to specify the number of the port it listens on, as follows (omitting the classpath):
java SimpleRegistryServer 2222
LocateSimpleRegistry and SimpleRegistry are just as LocateRegistry and Registry in Java RMI, except that they deal with the specified format for RORs rather than Java's original remote reference.
testRebind takes seven arguments. We use it as follows (omitting the classpath):
java testRebind 138.37.94.253 2222 ServiceName 12.12.12.12 2048 23 InterfaceName
This call is binding a ROR 12.12.12.12, 2048, 23, InterfaceName to ServiceName. Here 12.12.12.12 is the IP address which your Java RMI server listens to, 2048 is its port, 23 is the object id of the remote object, and IntefaceName is its interface name.
testLookup takes three arguments. We use it as follows (again omitting the classpath):
java testLookup 138.37.94.253 2222 ServiceName
For further information, look at the source code.