简体   繁体   English

RMI中实例化的存根在哪里

[英]Where is the stub instantiated in RMI

I am not sure where the instance of a stub for a remote object is created. 我不确定在哪里创建远程对象的存根的实例。 Is it created when registering it in the rmiregistry by calling calling Naming.bind ? 通过调用Naming.bind在rmiregistry中注册它时会创建它吗? This would make sense as the registry is also called via RMI. 这也很有意义,因为注册表也通过RMI调用。

But can't the stub also be created by calling UnicastRemoteObject.exportObject ? 但是也不能通过调用UnicastRemoteObject.exportObject创建存根吗?

This particular code snippet from oracle confused me: oracle的这个特定代码片段使我感到困惑:

Compute engine = new ComputeEngine();
Compute stub = (Compute) UnicastRemoteObject.exportObject(engine, 0);
String name = "Compute";
Registry registry = LocateRegistry.getRegistry();
registry.rebind(name, stub);

When using Naming.bind do I need to pass a stub or a remote object? 使用Naming.bind时,我是否需要传递存根或远程对象?

The stub is 存根是

  1. created when you export the remote object 在导出远程对象时创建
  2. substituted for the remote object when you pass the remote object as a remote method parameter or result, eg when binding or looking up in the Registry. 当您将远程对象作为远程方法参数或结果传递时(例如,在注册表中绑定或查找时)替换远程对象。

When using Naming.bind() do I need to pass a stub or a remote object? 使用Naming.bind() ,我是否需要传递存根或远程对象?

Either. 要么 It doesn't matter, because of (2). 没关系,因为(2)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM