是否可以在两个类之间使用RMI双向? [英] Is it possible to use RMI bidirectional between two classes?

查看:143
本文介绍了是否可以在两个类之间使用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,

Markus

推荐答案

如果 B 实现远程,它可以导出并作为参数在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双向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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