在RMI中传递远程参数 [英] Passing remote parameters in RMI

查看:192
本文介绍了在RMI中传递远程参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想确认有关RMI理论。

I would like to have confirm about RMI theory.

让我们假设客户端A向服务器B请求对象O的远程引用。

Let us suppose that Client A requests a remote reference of an object O to a Server B.

现在,如果在O接口(接口)中有这样的方法:
void foo(Interf obj);

Well, now if In O interface (Interf) there is a method like: void foo(Interf obj);

当客户端A调用O.foo(O)时,它将传递存根引用(在接收之前),然后服务器不使用其本地引用,而是使用存根对象(由客户端接收),因此服务器每次对O方法的调用将使用其TCP / IP服务。

When Client A calls O.foo(O) it passes stub reference (before received ) and then Server does not use its local reference but the Stub Object (received by Client), and so each call on O methods by Server will make use of its TCP/IP service.

可以吗?

您应该随意添加如果您认为这些细节可以提高我对RMI的理解,请提供一些细节。

You should feel free to add some details if you think that those can improve my RMI understanding.

问候

推荐答案

CORBA服务器(用于实现RMI / IIOP,而不是RMI / JRMP)通常实现共存存根优化。也就是说,如果服务器在存根上为驻留在同一进程中的对象调用方法,则CORBA服务器通常将避免TCP / IP和线程池分派开销。而是复制参数,将在目标对象上调用该方法,然后复制并返回结果对象。

CORBA servers (as used to implement RMI/IIOP, not RMI/JRMP) typically implement a "colocated stub" optimization. That is, if a server invokes a method on a stub for an object that resides in that same process, the CORBA server will typically avoid TCP/IP and thread pool dispatch overhead. Instead, the parameters are copied, the method will be invoked on the target object, and the result object is copied and returned.

作为参考,Java服务器通常实现此优化。 。生成的存根类使用 Util.isLocal 方法来确定存根目标是否为本地。接下来,Stub。 _ servant_preinvoke 以获得对本地仆人的引用/代理,以及 Util.copyObjects (或Util.copyObject)用于复制参数并返回对象。 (异常处理,RemarshalException等还有其他复杂性,但我已经概述了基本流程。)

For reference, Java servers typically implement this optimization. The generated stub classes use the Util.isLocal method to determine if a stub target is local. Next, Stub._servant_preinvoke is called to obtain a reference/proxy to the local servant, and Util.copyObjects (or Util.copyObject) is used to copy parameters and return objects. (There are additional complexities with exception handling, RemarshalException, etc., but I've outlined the basic flow.)

这篇关于在RMI中传递远程参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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