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
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 ...