Reputation: 641
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.
Upvotes: 3
Views: 808
Reputation: 14636
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...
Upvotes: 7