简体   繁体   English

使用UnicastRemoteObject.exportObject的返回值和导出的对象之间有区别吗?

[英]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.

相关问题 Java RMI - UnicastRemoteObject:UnicastRemoteObject.exportObject()和扩展UnicastRemoteObject有什么区别? - Java RMI - UnicastRemoteObject: what is the difference between UnicastRemoteObject.exportObject() and extends UnicastRemoteObject? UnicastRemoteObject.exportObject(this,0); - UnicastRemoteObject.exportObject(this, 0); Java:调用UnicastRemoteObject.exportObject()时的完整GC? - Java: a full GC when UnicastRemoteObject.exportObject() is called? 在类UnicastRemoteObject的方法'exportObject'中使用固定端口号时,出现NoSuchObjectException - NoSuchObjectException when using fixed port number in method 'exportObject' of class UnicastRemoteObject 是否可以导出UnicastRemoteObject,然后将其作为参数传递 - Can UnicastRemoteObject be exported and then passed as argument Java-“返回对象”和“返回(对象)”之间的区别 - Java - Difference between “return object” and “return (object)” RMI:来自服务器的对象,引用为UnicastRemoteObject - RMI: object from server with reference as UnicastRemoteObject 在类中使用方法返回值与引用精确值本身之间的区别 - Difference between using a method in a class to return a value and referencing the exact value itself 在“ this”和私有“ new Object”上使用同步之间的区别? - Difference between using synchronized on “this” and a private “new Object”? JNA中GlobalAlloc和GlobalLock的返回值有什么区别 - What is the difference of return value between GlobalAlloc And GlobalLock in JNA
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM