简体   繁体   中英

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?

I am just very curious because it is not possible to use a @RequestScoped Managed Bean in a SessionScoped Managed Bean as managed property.

Why is it possible to @Inject a @Stateless EJB into a @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.

I am just very curious because it is not possible to use a @RequestScoped Managed Bean in a SessionScoped Managed Bean as managed property.

You are referring to the JSF scopes, not the CDI scopes, right? 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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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