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

Examining the Registry

bind( ), lookup( ), rebind( ), and unbind( ) are all straightforward and easy to understand. However, list( ) is a somewhat stranger method. It enables a client application to find the URLs of all the servers bound into a particular registry. At first glance, this isn’t particularly useful. There are, however, two cases when this can be a very useful property.

The first case occurs when the results of querying the RMI registry are combined with reflection. That is:

  • list( ) enables a client to find all the servers in the registry.

  • Java’s support for reflection enables the client to discover the interfaces each server implements and thus find a particular server (or give the user a choice of appropriate servers).

The second case when list( ) is useful occurs when the registry isn’t used as a general-purpose registry, but is instead application-specific. Note that this second case is really a special case of the first, in which we don’t need reflection. That is, in the first case we use reflection to find a subset of the servers that meet our application-specific criteria. In the second case, we know in advance, because we are using a specific registry with a specific purpose, that the servers returned by list( ) meet our application-specific criteria.

To make this more concrete, consider our remote printer application once again. Suppose we decide on a logical naming convention consisting of the following three components:

  • Location. A human-readable string ...

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