O'Reilly logo

Java RMI by William Grosso

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The RMI Registry

We’ve done three things with the RMI registry: we’ve launched the actual registry server, we’ve bound objects into the registry using strings for names, and we’ve looked up objects in the registry.

All of the code we’ve written has used static methods on the java.rmi.Naming class to accomplish these tasks. In particular, Naming defines the following five static methods:

public static void bind(String name, Remote obj) 
public static void rebind(String name, Remote obj) 
public static void unbind(String name) 
public static String[] list(String name) 
public static Remote lookup(String name)

These methods naturally divide into two sets: those called by the launch code and those called by clients. The launch-code methods, bind( ), unbind( ), and rebind( ), deal with the mechanics of inserting and removing servers from a registry. The client methods, list( ) and lookup( ), deal with querying a registry to find a server.

bind( ), rebind( ), and unbind( )

These three methods deal with binding or unbinding a server into the registry. Each of them takes a string argument called name. In addition, bind( ) and rebind( ) take an instance of a class that implements the Remote interface. The first thing that any of them do is parse name to find out where the registry is running. name is a combination of the location of the RMI registry and the logical name of the server. That is, it is a URL with the following format:

//registryHost:port/logical_name

Both host and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required