简体   繁体   English

RMI - 谁调用了该方法

[英]RMI - who invoked the method

is there a way to know what server/client invoked a method on the server? 有没有办法知道服务器/客户端调用服务器上的方法?

Problem: I have a completely connected graph of server, and when a command comes in from a client on one of the server nodes, I forward it to the rest of the server nodes on the graph. 问题:我有一个完全连接的服务器图,当一个命令从一个服务器节点上的客户端进来时,我将它转发到图上的其余服务器节点。 I want to only forward the commands if and only if it's coming from a client and not another server. 我想只转发命令,当且仅当它来自客户端而不是来自另一台服务器时。

Rather than trying to find out the client, why not provide two implementations of the server object? 而不是试图找出客户端,为什么不提供服务器对象的两个实现? One that forwards requests, and one that doesn't? 一个转发请求,一个不转发请求? I would subclass the forwarding version from the non-forwarding version, and register them under different names. 我会从非转发版本继承转发版本,并以不同的名称注册它们。

However, it seems to me that you really want a messaging architecture rather than RMI between the servers. 但是,在我看来,您确实需要消息体系结构而不是服务器之间的RMI。

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

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