简体   繁体   English

自定义Scoped Bean JSF 2.0

[英]Custom Scoped Bean JSF 2.0

Hi I have a bean and I want to define it as a CustomScoped Bean based on time, I mean I want to destroy the bean after a specific period of idle time . 嗨,我有一个bean,我想根据时间将其定义为CustomScoped Bean,我的意思是我想在一段特定的空闲时间后销毁它。 I mean if the user is not working with his/her own instance of the bean, the bean should be destroyed. 我的意思是如果用户没有使用他/她自己的bean实例,那么bean应该被销毁。 Yes, each user needs to have its own instance, so it will be a kind of SessionScoped Bean which will be removed from Session after a while... 是的,每个用户都需要拥有自己的实例,因此它将是一种SessionScoped Bean,它将在一段时间后从Session中删除...

JSF 2.0首席开发人员Ryan Lubke的这篇博客文章包含一个WAR风格的例子

If you can use CDI (JSR-299) , you could use the Conversation Scope, make it long lived, and set the conversation timeout to your desired value. 如果您可以使用CDI(JSR-299) ,则可以使用“对话范围”,使其保持较长时间,并将对话超时设置为所需的值。 This would save you from having to write your own custom scope. 这样可以避免编写自己的自定义范围。 As an added bonus, you get all the other great things that come with CDI. 作为额外的奖励,您可以获得CDI附带的所有其他优点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM