问题描述
我有了与 @ preDestroy
注释,应该做一个方法的 @ViewScoped
豆肯定有些远程连接被关闭。然而,当用户导航离开该方法不被调用。
I have a @ViewScoped
bean that has a method with an @PreDestroy
annotation that should make sure some remote connections are closed. However, the method is not called when the user navigates away.
有什么可以做的不对?我必须以使其工作?任何地方注册任何
Is there anything one can do wrong? Do I have to register anything anywhere in order to make it work?
这是一个简单的方法公开(无效
)抛出也不例外。
It's a simple public method (void
) that throws no exception.
我使用JSF 2(MyFaces的)和Tomcat 7.0.12。难道是一个问题,Tomcat的?
I'm using JSF 2 (MyFaces) with Tomcat 7.0.12. Could it be a problem with Tomcat?
更新
的 @PostConstruct
注释工作正常。
推荐答案
这是一个已知问题,遗憾的是不平凡的,没有让所有的导航发生通过视图范围问题bean来解决。另请参见。这并不仅没有涵盖终端用户改变URL在浏览器地址栏或关闭窗口/标签的情况。他们的 @ preDestroy
将在会议上被摧毁也不会被调用。为规范中的增强请求然而,已经发布到拿到悬挂意见,会议期间灭灭反正:。
This is a known issue and unfortunately not trivial to solve without letting all the navigation take place through the view scoped bean in question. See also JSF-impl issue 1839. This does only not cover cases where the enduser changes the URL in browser address bar or closes the window/tab. Their @PreDestroy
will also not be called when the session get destroyed. An enhancement request for the specification has however been posted to get the dangling views to destroy during session destroy anyway: JSF-spec issue 905.
这篇关于@ preDestroy从来没有号召@ViewScoped的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!