简体   繁体   English

Java RMI-将客户端存根发送到其他客户端

[英]Java RMI - send Client stubs to other clients

I've got to implement something like P2P in RMI. 我必须在RMI中实现类似P2P的功能。 I've created two Remote intrfaces : server and client. 我创建了两个远程接口:服务器和客户端。 Server is responsible for registering clients and returning client stubs to other clients that request it. 服务器负责注册客户端,并将客户端存根返回给其他请求它的客户端。 How should I accomplish this? 我应该如何做到这一点? The method signature on the server looks like this: 服务器上的方法签名如下所示:

IClient getClient(String resource) throws RemoteException;

The problem is I don't really know how should I implement that regarding the stubs&skeleton issues and that many things is happening behind the scenes. 问题是我真的不知道应该如何处理存根和骨架问题,并且幕后正在发生许多事情。

You don't have to worry about it since JDK 1.5. 从JDK 1.5开始,您不必担心。 See the preamble to the Javadoc for UnicastRemoteObject. 请参见UnicastRemoteObject的Javadoc序言。 As long as you quote a port number, even zero, when calling super() or exportObject you don't need stubs. 只要在调用super()或exportObject时引用端口号,甚至为零,就不需要存根。 And you haven't needed skeletons since 1998. 从1998年开始,您就不再需要骨骼了。

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

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