简体   繁体   English

为什么可以将@Stateless EJB注入@SessionScoped Managed Bean?

[英]Why is it possible to @Inject a @Stateless EJB into a @SessionScoped Managed Bean?

Why is it possible to @Inject a @Stateless EJB into a @SessionScoped Managed Bean? 为什么有可能@Inject一个@Stateless EJB成@SessionScoped Managed Bean的?

I am just very curious because it is not possible to use a @RequestScoped Managed Bean in a SessionScoped Managed Bean as managed property. 我只是很好奇,因为不可能在SessionScoped Managed Bean中使用@RequestScoped Managed Bean作为托管属性。

Why is it possible to @Inject a @Stateless EJB into a @SessionScoped Managed Bean? 为什么可以将@Stateless EJB注入@SessionScoped Managed Bean?

That makes perfect sense. 这很有道理。 You might want to access a stateless component (eg a validation service) from within a stateful service (eg a shopping process). 您可能希望从有状态服务(例如购物流程)中访问无状态组件(例如验证服务)。 CDI references are proxied , so there is no technical problem with the resolution. CDI引用是代理的 ,因此解决方案没有技术问题。

I am just very curious because it is not possible to use a @RequestScoped Managed Bean in a SessionScoped Managed Bean as managed property. 我只是很好奇,因为不可能在SessionScoped Managed Bean中使用@RequestScoped Managed Bean作为托管属性。

You are referring to the JSF scopes, not the CDI scopes, right? 您指的是JSF范围,而不是CDI范围,对吧? I cannot tell why that constellation might be forbidden, but both specifications are completely unrelated, so there is no " if A is true in JSF then B must be true in CDI "-relationship... 我不知道为什么这个星座可能是被禁止的,但两个规范都是完全不相关的,所以没有“ 如果A在JSF中是真的那么B必须在CDI中是真的 ” - 关系......

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

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