Seam 会话范围组件在下一个请求中消失
我有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于你的第一个问题:该组件是在
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 codeorg.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 propertyrequire=false
, theuser
that is currently outjected in your session context may be overridden bynull
.