服务器如何与 RMI 中的客户端进行会话 [英] How a server can make a session with a client in RMI

查看:27
本文介绍了服务器如何与 RMI 中的客户端进行会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人告诉我在哪里搜索如何在 RMI 中的客户端和服务器之间建立会话,即用于搜索目的的概念的名称是什么?

I want someone to tell me where to search for how to make a session between the client(s) and the server in RMI, i.e what is the name of that concept for searching purposes?

推荐答案

我在 2001 年的书中将其命名为远程会话模式.

I named this the Remote Session pattern in my 2001 book.

这个想法是有一个单一的 RMI 对象,绑定在注册表中,只有一个 login() 方法.如果成功,该方法将为每次调用返回一个新的 RemoteSession 对象,其中包含会话所需的 API.RemoteSession 当然是另一个远程接口.它还包含一个 logout() 方法,用于取消导出对象,并且它还实现了 Unreferenced,作为另一种终止会话的方式.

The idea is to have a singleton RMI object, bound in the Registry, with nothing but a login() method. That method, if successful, returns a new RemoteSession object for every call, that contains the API you need for the session. RemoteSession is another remote interface of course. It also contains a logout() method, which unexports the object, and it also implements Unreferenced, as another way of terminating the session.

RemoteSession 的每个实例都可以维护客户端状态,因此它是一个会话对象,并且因为获取 RemoteSession 对象的唯一方法是通过 login(),所以它是安全的一级近似.

Each instance of RemoteSession can maintain client state, so it is a session object, and as the only way to get a RemoteSession object is via login(), it is secure to a first approximation.

这篇关于服务器如何与 RMI 中的客户端进行会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆