类java.rmi.registry.Registry和java.rmi.Naming之间的区别 [英] Difference between classes java.rmi.registry.Registry and java.rmi.Naming

查看:407
本文介绍了类java.rmi.registry.Registry和java.rmi.Naming之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注册表类和命名类有什么区别。

在我的应用程序中,我使用 Registry 类。但我想知道命名类及其用途?

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

推荐答案

区别在于命名是一个带有静态方法的实用程序类,而 Registry 是一个远程接口。不出所料,命名在内部调用注册表。请注意,传递给 java.rmi.Naming 名称参数是URL格式,并包含注册表,而 java.rmi.registry.Registry 名称只是名称。

The difference is that Naming is a utility class with static methods, while Registry is a remote interface. Unsurprisingly, Naming calls Registry internally. Note 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.

例如,您可以这样调用:

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 = LocateRegistry.getRegistry("host");
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.

这篇关于类java.rmi.registry.Registry和java.rmi.Naming之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆