Using the RMI Registry

You've already seen the two most important methods in the Naming class (the interface to the RMI Registry). They are rebind and lookup. The rebind method, of course, associates a name with a remote object. The Naming class also includes a bind method that associates a name with an object. The difference between bind and rebind is that bind fails if the Registry already contains an object with the same name. Depending on the application, you might not want to overwrite an existing name, and in those cases, you use bind instead of rebind.

To remove an entry from the RMI Registry, use the unbind method. You specify the name you want to remove, like this:

Naming.unbind("//flamingo/TestObject");

You can get a list of the names ...

Get Special Edition Using Java™ 2 Enterprise Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.