Consider Using a Naming Service
A naming service, such as the RMI registry or a JNDI service provider, provides a very simple piece of functionality: it lets a client application pass in a logical name (such as “BankAccountServer”) and get back a stub to the requested server.
This level of indirection is incredibly useful. It makes writing the
client code much simpler, it means that you don’t
have to figure out another way to get stubs to the servers (which
isn’t so hard: RemoteStub does
implement Serializable), and it allows you to
easily move servers to different machines.
In short, using a naming service makes it much easier to write and deploy applications.
Tip
Using a naming service also makes it possible to use the
Unreferenced interface reliably.
We’ll talk more about this later in the chapter.