[英]Is there a difference between using the return value of UnicastRemoteObject.exportObject and the exported object?
When exporting an object I find that both this 导出对象时,我发现这两个
LocateRegistry.createRegistry(1099);
ObjectToExport obj = new ObjectToExport();
UnicastRemoteObject.exportObject(obj, 1099);
Naming.rebind("ObjectName", obj);
and this 和这个
LocateRegistry.createRegistry(1099);
ObjectToExport obj = new ObjectToExport();
Naming.rebind("ObjectName", UnicastRemoteObject.exportObject(obj, 1099));
work. 工作。 In the first I don't use the return value of exportObject
and in the second I do. 在第一个中,我不使用exportObject
的返回值,在第二个中,我使用。 Is there a difference between these 2 ways of exporting an object? 这两种导出对象的方式之间有区别吗? The API only says that the return value is the remote object stub
. API仅表示返回值是remote object stub
。
There is no difference at the export step, but you're also binding the object, and there's a difference at this step. 在导出步骤没有什么区别,但是您还要绑定对象,并且在此步骤也有所区别。 In the first step you're passing the actual object; 第一步,您要传递实际对象; in the second, the stub. 第二个是存根。 However the semantics of RMI are that exported remote objects are passed to remote methods as their own stubs, so the actual effect at the Registry is the same. 但是 ,RMI的语义是将导出的远程对象作为它们自己的存根传递给远程方法,因此在注册表处的实际效果是相同的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.