Is it possible to use RMI bidirectional between two classes?(是否可以在两个类之间使用 RMI 双向?)
问题描述
我想在两个类(A 和 B)之间共享一些信息,它们在不同的 java 程序中运行.我不想编写一个完整的通信协议,而是为此目的使用 java 内置 rmi 类.目前 B 类能够远程运行属于 A 类的方法.是否可以在 A 类中使用相同的连接"来调用 B 类的方法?否则我可能不得不实现第二个 rmi 服务......
I want to share some information between two classes (A and B), which are running in different java programs. Instead of writing a whole communication protocol I want to use the java build-in rmi classes for that purpose. Currently class B is able to run a method which belongs to class A remotely. Is it somehow possible to use the same "connection" within class A to call a method of class B? Otherwise I probably have to implement a second rmi service ...
BR,
马库斯
推荐答案
如果B
实现了Remote
,则可以在RMI调用中导出并作为参数传递给A
.在这种情况下,不需要在 RMI 注册表中注册 B
,因为客户端被显式地传递了对它的引用.
If B
implements Remote
, it can be export and passed as a parameter in an RMI call to A
. In this scenario, there's no need to register B
in an RMI registry, since the client is being passed a reference to it explicitly.
这篇关于是否可以在两个类之间使用 RMI 双向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否可以在两个类之间使用 RMI 双向?


基础教程推荐
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- 在螺旋中写一个字符串 2022-01-01