简体   繁体   English

注入JSF @SessionScoped中的@Stateless EJB的寿命是什么?

[英]What is the life of @Stateless EJB injected into JSF @SessionScoped?

I'm converting some code to take advantage of EJB 3 and I've come up with a scenario where I have a @Stateless EJB being injected into JSF Managed bean that is annotated with @SessionScoped. 我正在转换一些代码以利用EJB 3,并且提出了一个方案,其中将@Stateless EJB注入到带有@SessionScoped注释的JSF受管bean中。

I was wondering how this effected the life of the EJB? 我想知道这如何影响EJB的寿命? Does it remain stateless and get destroyed after each call to one of its methods or does the same bean exist for the duration of the session? 它是保持无状态并在每次调用其方法之一后被销毁吗?还是在会话期间存在相同的bean?

As stateless EJB session beans are pooled by the server, there is no direct relationship with their lifecycle and the lifecycle of other session scoped beans. 由于无状态EJB会话Bean由服务器池化,因此与其生命周期以及其他会话作用域Bean的生命周期没有直接关系。 The webserver creates and destroys such beans when it needs to. Web服务器在需要时创建并销毁此类bean。
From the EJB spec: 从EJB规范:

The container can perform the instance creation at any time—there is no direct relationship to a client's invocation of a business method or the create method. 容器可以随时执行实例创建-与客户对业务方法或创建方法的调用没有直接关系。

For more information see the specification (around page 99). 有关更多信息,请参见规格 (第99页左右)。

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

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