1

我正在转换一些代码以利用 EJB 3,并且我想出了一个场景,我将一个 @Stateless EJB 注入到使用 @SessionScoped 注释的 JSF Managed bean 中。

我想知道这如何影响 EJB 的生命周期?它是否保持无状态并在每次调用其方法之一后被销毁,或者在会话期间是否存在相同的 bean?

4

1 回答 1

2

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. The webserver creates and destroys such beans when it needs to.
From the EJB spec:

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).

于 2013-05-21T14:33:01.203 回答