Seam 会话范围组件在下一个请求中消失

发布于 2024-09-27 15:28:28 字数 610 浏览 9 评论 0原文

我有 Seam 会话范围的组件 CustomIdentity,它覆盖了标准 Seam Identity(也是会话范围的)。扩展的 CustomIdentity 有一个属性,

@Out(required=false, scope=ScopeType.SESSION)private User user

在重写的 login() 中,我定义了一个 User 对象,其中填充了来自 HttpServletRequest 主体的信息。在应用程序的第一个请求中,User 对象按预期在 SESSION 范围内被抛出。但是,在第二个请求中,用户对象已从会话中消失,当我访问注入它的页面时,我收到异常。

我的问题是组件何时被注入:

  • 在 CustomIdentity 组件的每一个方法之后(即使它不包含 user 的引用)?
  • 在每个包含 User 组件引用的方法之后?

关于 required 属性:

  • 如果在退出时 User 对象的计算结果为 null,那么已经退出的 User 是否会从 Session 范围中删除?

干杯!

I have the Seam session-scoped component, CustomIdentity which overrides the standard Seam Identity (also session-scoped). The extended CustomIdentity has a property

@Out(required=false, scope=ScopeType.SESSION)private User user

In the overriden login() I define a User object, populated with information from the Principal of the HttpServletRequest. In the first request in the application the User object is outjected as expected in SESSION scope. In the second request, though, the User object has vanished from the Session, and when I visit a page that Injects it, I get an exception.

My question is when exactly the component is outjected:

  • After each and every one method of the CustomIdentity component (even if it does not contain a reference of user)?
  • After each method that contains a reference of the User component?

And about the required attribute:

  • If upon outjection the User object evaluates to null, is the already outjected User going to be removed from Session scope?

Cheers!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

走走停停 2024-10-04 15:28:28

对于你的第一个问题:该组件是在 CustomIdentity 的每个方法之后被注入的。看一下相应的Seam源代码org.jboss.seam.core.BijectionInterceptor(Seam 2.2.0)。双射发生在组件,即类、级别。

对于第二个问题:每次对 CustomIdentity 的请求完成时,您的字段的值都会被抛出。如果您使用 outjection 属性 require=false,当前在会话上下文中 outjection 的 user 可能会被 null 覆盖。

To your first question: the component is oujected after each and every method of CustomIdentity. Take a look at the corresponding Seam source code org.jboss.seam.core.BijectionInterceptor (Seam 2.2.0). Bijection takes place at component, i.e., class, level.

To your second question: every time a request to CustomIdentity finishes, the value of your field is outjected. If you use the outjection property require=false, the user that is currently outjected in your session context may be overridden by null.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文