RMI IIOP 客户端对象作为回调
我正在尝试构建 rmi-iiop 应用程序(非常简单的聊天)。 我需要服务器能够与客户端通信,所以我的想法是创建连接用户的接口:
public interface UserInterface extends Remote {
public void receiveMessage(String message) throws RemoteException;
}
然后在客户端使用服务器可以执行的方法创建用户类('receiveMessage'):
public class User extends PortableRemoteObject implements UserInterface {
protected User() throws RemoteException {
super();
}
@Override
public void receiveMessage(String message) throws RemoteException {
client.addMessageToGUI();
}
}
我使用rmic -iiop Chat User< /code> 生成
_Chat_Tie.class _ChatInterface_Stub.class _User_Tie.class _UserInterface_Stub.class
将所有文件放在服务器端和客户端并运行应用程序后,我得到以下错误: java.rmi.StubNotFoundException:未找到存根类:User_Stub;嵌套异常是:
我想这里的区别是聊天类是在服务器上创建的,然后客户端使用它使用接口(工作正常),但用户类必须在客户端创建,所以客户端部分工作一台服务器。
我的问题类似于 Java RMI - 让客户端成为服务器 但对于 rmi-ioop 实现。
简而言之 - 如何将本地对象引用发送到服务器,以便它可以对其执行操作?
谢谢! 莱昂蒂
I'm trying to build rmi-iiop application (very simple chat).
I need server to be able to communicate with client so my thinking was to create interface of connected user:
public interface UserInterface extends Remote {
public void receiveMessage(String message) throws RemoteException;
}
Then on client side create User class with methods server can execute('receiveMessage'):
public class User extends PortableRemoteObject implements UserInterface {
protected User() throws RemoteException {
super();
}
@Override
public void receiveMessage(String message) throws RemoteException {
client.addMessageToGUI();
}
}
I use rmic -iiop Chat User
which generates _Chat_Tie.class _ChatInterface_Stub.class _User_Tie.class _UserInterface_Stub.class
After placing all files on server side and client side and running the application I get following error:java.rmi.StubNotFoundException: Stub class not found: User_Stub; nested exception is:
I guess the difference here is that Chat class is created on server and then client uses it using interface (which works fine), but user class has to be created on client side, so client works partly as a server.
My question is similar to Java RMI - Making the client a server
but for rmi-ioop implementation.
So in to words - how can I send local object reference to server so it could perform operations on it?
Thanks!
Leonty
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您创建一个服务器接口,例如:
you create a server interface like:
我缺少的是客户端的“Tie”类(_User_Tie.class)。通常不需要它,但如果在客户端创建对象,我也需要提供它。
希望它将来能为其他人节省一些时间:)
What I was missing is "Tie" class on client side (_User_Tie.class). Usually it's not needed but in case when object is created on client side - I needed to supply it also.
Hope it saves some time for someone else in a future :)