Java RMI 和远程文件访问
我刚刚开始学习Java的RMI,并且相信我理解这个过程,客户端发送方法请求和参数,服务器进行计算并将返回结果发回。
但是,服务器是否在本地执行该方法中的所有操作?
具体来说,如果在该方法中读取文件,我认为这是由服务器执行的是否正确?
如果是这种情况,是否有任何方法可以专门从客户端访问资源(例如客户端的 System.out?)
I'm just starting to learn Java's RMI, and believe I understand the process, client sends method requests and params, server does computation and sends return result back.
However does the server perform everything within the method locally?
Specifically, if a file is read in the method, am I correct in thinking this is performed by the server?
If this is the case is there any way for the method to specifically access resources from the client (such as the client's System.out?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
话虽如此,客户端也可以充当服务器,导出自己的远程对象,该对象可以传递给(其他)服务器,然后服务器可以使用该远程对象来回调客户端。
Serializable
, and streams typically aren't.Having said that, a client can also act as a server, exporting its own remote objects, which can be passed to the (other) server, which can then use that remote object to call the client back.
如果我理解你的问题,我会说是的,你是对的。根据定义,(远程)方法在服务器端运行。客户端只持有一个假对象(代理或存根),它与服务器建立连接,传递参数并为您获取返回值。
想想客户端和服务器运行在不同的机器上,服务器无法知道客户端的资源,除非客户端将自己充当服务器。
问候
If I understand your question, I say yes, your'e correct. By definition the (remote)method runs on the server side. The client just holds a fake object (proxy or stub) that makes the connection to the server, passes the arguments and gets the return value for you.
Think about the client and server running in different machines, there's no way to server knows anything about the client's resources, unless the client acts itself as a server.
Regards
您可以使用 rmiio 通过 rmi 轻松传输数据。这就是说我非常怀疑你会想用 System.out 来做到这一点。
You can use rmiio to easily stream data over rmi. that said i highly doubt you would want to do that with System.out.