本文介绍了RMI 服务器:rmiregistry 或 LocateRegistry.createRegistry的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于服务器端的RMI,我们需要启动rmiregistry程序,还是直接调用LocateRegistry.createRegistry?如果两者都可能,有什么优点和缺点?

For RMI on server-side, do we need to start rmiregistry program, or just call LocateRegistry.createRegistry?If both are possible, what are the advantages and disadvantages?

推荐答案

它们是一样的... rmiregistry 是一个单独的程序,您可以从命令行或脚本运行它,而 LocateRegistry.createRegistry 以编程方式执行相同的操作.

They're the same thing... rmiregistry is a separate program, which you can run from a command line or a script, while LocateRegistry.createRegistry does the same thing programatically.

根据我的经验,对于真正的"服务器,您需要使用 rmiregistry 以便您知道无论客户端应用程序是否启动,它始终在运行.createRegistry 对于测试非常有用,因为您可以根据需要从测试中启动和停止注册表.

In my experience, for "real" servers you will want to use rmiregistry so that you know it's always running regardless of whether or not the client application is started. createRegistry is very useful for testing, as you can start and stop the registry from your test as necessary.

这篇关于RMI 服务器:rmiregistry 或 LocateRegistry.createRegistry的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 05:25