类 java.rmi.registry.Registry 和 java.rmi.Naming 之间的区别
Registry
类和 Naming
类之间有什么区别。
在我的应用程序中,我使用 Registry
类。但我想了解 Naming
类及其用途?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不同之处在于
Naming
是一个具有静态方法的实用程序类,而Registry
是一个远程接口。毫不奇怪,Naming
在内部调用Registry
。请注意,传递给java.rmi.Naming
的name
参数采用 URL 格式,并包含注册表的位置,而使用java.rmi.registry .Registry
,名称
只是名称。例如,您可以这样调用:
而对于
Registry
,您需要注册表对象上的现有句柄,并且您可以调用:所以
Naming
实际上只是一个方便的类使您不必手动查找注册表 - 它一步执行注册表查找并重新绑定。The difference is that
Naming
is a utility class with static methods, whileRegistry
is a remote interface. Unsurprisingly,Naming
callsRegistry
internally. Note that thename
arguments you pass tojava.rmi.Naming
are in URL format, and include the location of the registry, whereas withjava.rmi.registry.Registry
, thename
is just the name.For example, you would call something like this:
whereas with
Registry
, you need an existing handle on the registry object, and you'd call:So
Naming
is really just a convenience class that saves you having to look up theRegistry
manually - it performs the registry lookup and rebind in one step.