【发布时间】:2013-01-08 16:11:21
【问题描述】:
看看the unrelated portion of this answer to another question,虽然我理解为什么在问题示例中对请求和响应的引用是线程不安全的,为什么 SessionScoped bean 引用它所绑定的 HttpSession 是线程不安全的?
@SessionScoped
public class SessionManager {
HttpSession session = null;
...
@PostConstruct void initialize() {
this.session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false);
}
private void onLogin(@Observes @LoggedIn User user) {
// (1) housekeeping stuff
// (2) destroy older, duplicate login session, if user did not previously
// logout, in which case it would be really handy to have a reference
// to HttpSession.
}
}
【问题讨论】:
标签: jsf-2 cdi httpsession