java - Java RMI 有什么意义?

标签 java rmi

为什么存在 Java RMI?谁使用它以及用途是什么?

我最紧迫的问题;

  • 为什么要调用您的计算机上未定义的方法?执行起来不是要花更长的时间吗?我不明白这如何让世界变得更美好。让许多机器运行完整的程序而不是让许多机器分别运行部分程序不是更聪明吗?
  • 您必须手动为所有计算机(客户端和服务器)提供接口(interface),这一事实是否会消除远程对象提供的任何好处?换句话说,如果拥有远程对象的好处是客户端程序员不必与服务器程序员交互,那么手动相互联系以更新双方的接口(interface)不是很烦人吗?改变?
  • 这与客户端与服务器通信的典型 Web 应用程序设置有何相似或不同?在我看来,HTTP 调用更容易理解。 RMI 服务器可以要求 RMI 客户端提供某种密码吗?
  • 通常使用 Java RMI 构建什么类型的应用程序?有什么具体的例子吗?

最佳答案

Why does Java RMI exist?

呃,因为 Sun build 了吗?提供 Sun RPC 的同一 Sun .

Who uses it and for what?

RMIJakarta EE 的基础(以前称为 J2EE)仅举一个小例子。然而remote method calls的概念至少可以追溯到CORBA ,以及 remote procedure calls 的概念至少到 20 世纪 70 年代。 Sun 大约在 1982 年提供了 RPC 的实现,它是 NFS 的基础除其他事项外。

Why would you want to make calls to methods that aren't defined on your machine?

呃,如果您希望它们在另一台机器上运行?

Wouldn't it take much longer to execute?

当然。

I don't see how this makes the world a better place. Wouldn't it just be smarter to have many machines running the complete program rather than many machines each running parts?

所以你从来没有听说过 distributed computing ,然后呢?

Doesn't the fact that you have to manually provide interfaces to all the machines (clients and servers) kill whatever benefits having remote objects provides?

没有。

In other words, if a benefit of having a remote object is that the client programmer doesn't have to interact with the server programmer

有人说这是一个好处吗?

then doesn't it get annoying to have manually contact each other to update the interfaces on both sides for each little change?

如果您在实现系统之前实际​​设计系统,那么往往不会有很多“小变化”。但这并不是唯一的开发模式。您可以让第三人开发界面。或者是同一个人开发两侧。或者具有由规范定义的远程接口(interface)。或者...

How is this similar or different to a typical web app set up where a client communicates with a server?

它使用 RMI 而不是 HTTP .

In my mind, HTTP calls are much easier to understand.

没有比远程界面更容易理解的了,但显然您的理解程度有所不同。

Can an RMI Server require some sort of password from RMI clients?

是的,它可以使用相互验证TLS例如,或通过自定义套接字工厂实现的任意身份验证协议(protocol)。

关于java - Java RMI 有什么意义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32929950/

相关文章:

java - 如何使用 Google Spreadsheet API 将一个单元格的样式复制到另一个单元格中

java - 在 Ubuntu 上设置 Java 环境路径时出现问题 (libjvm.so : cannot open shared object file: No such file or directory)

Java windowBuilder - 如何显示 "File already exists"警告?

java - RMI 注册表过滤器拒绝 java 8 update 121 中的 Rmi 配置类

java RMI - 多个主机注册具有相同名称的对象

java - RMI 转 HTTP 协议(protocol)

java - Spring MVC : ServletContext in JUnit Test?

java - 假装: Retry depending on response status

java.rmi.ConnectException : Connection refused to host: 192. 168.1.8;嵌套异常是:

osgi - 适合 ERP 等应用程序的框架