重用客户端会话提取逻辑
我希望能够重用现有的控制器逻辑,无论请求是从 Flex 客户端(在后端使用 BlazeDS + Spring)发送的,还是作为简单的 HTTP POST/GET 请求发送的。对于简单的情况,一切正常,但是,在某些情况下我需要访问某些会话属性。起初,我几乎只使用 FlexContext 类,但后来我意识到,当发送 HTTP 请求时,Flex Context 显然是未定义的。
我的问题是,无论请求的类型如何,抽象会话提取逻辑的最佳方法是什么。换句话说,我将创建一个名为 SessionManager 的类,它有一个 getSession 方法。该类将检查是否存在 Flex 上下文,如果存在,它将返回该上下文的会话。如果没有,它只会返回当前的 HTTP 会话(我假设它与 Flex 客户端会话相同,但我不确定)
有什么意见吗?
I want to be able to reuse my existing controller logic regardless of whether a request has been sent from a Flex client (using BlazeDS + Spring at the backend), or as a simple HTTP POST/GET request. For simple cases, things work OK, however, there are some occasions when I need to access some session attributes. At first, I almost exclusively used the FlexContext class, but then I realized that when one sends an HTTP request, then the Flex Context is obviously undefined.
My question is, what is the best approach to abstract the session extraction logic,regardless of the type of the request. In other words, I would make a class called SessionManager, which has a method getSession. This class will make a check whether there is a Flex context, if there is, it will return the session of that context. If not, it will simply return the current HTTP session (which I assume is the same as the Flex client session, but I was not sure)
Any comments?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定我是否理解你的问题。当 Flex 客户端访问服务器时,您是否尝试从 FlexSession 中读取数据;如果是非 Flex 客户端,您是否尝试从 HttpSession 中读取数据?如果是这样,也许你可以尝试这样的事情......我目前没有设置来测试这个,如果它不起作用或者这不是你要问的,那么很抱歉。
Not sure if I understand your question right. Are you trying to read from the FlexSession when a flex client accesses the server and from the HttpSession in case of a non-flex client? If so, maybe you can try something like this ... I don't have a setup currently to test this so sorry if it doesn't work or if this isn't what you are asking about.