tags:

views:

16

answers:

1

What is the difference between the Registry class and Naming class.

In my application I am using Registry class. But I want to know about Naming class and its uses ?

+2  A: 

They do look suspiciously similar, don't they?

The difference is that the name arguments you pass to java.rmi.Naming are in URL format, and include the location of the registry, whereas with java.rmi.registry.Registry, the name is just the name.

Also, the methods on Naming are static.

For example, you would call something like this:

Naming.rebind("//host/objName", myObj);

whereas with Registry, you need an existing handle on the registry object, and you'd call:

Registry registry = ...
registry.rebind("objName", myObj");

So Naming is really just a convenience class that saves you having to look up the Registry manually - it performs the registry lookup and rebind in one step.

skaffman