[jsr-314-open-mirror] [jsr-314-open] CDI constructor integration
Stephen Kenna
kenna at us.ibm.com
Thu Jun 24 10:42:03 EDT 2010
We have internally been discussing @Inject into @ManagedBeans (should be
the same for JSF Managed beans defined in the faces-config.xml).
Originally we were trying to figure out if JSF managed beans should
support constructor injection if they were inside a BDA (in other words,
if JSF should defer to CDI for creation).
We did some testing on Glassfish, and not only did constructor injection
not occur, but field injection did not occur either. (Field injection is
working on JBoss)
My reading of JSR-299 & the EE6 spec differs from this.
>From JSR299 Section 1.2.1:
In the Java EE 6 environment, all component classes supporting injection,
as defined by the Java EE 6 platform specifica-
tion, may inject beans via the dependency injection service.
Or JSR299 Section 3.8:
An injected field is a non-static, non-final field of a bean class, or of
any Java EE component class supporting injection.
>From the EE6 spec, Section EE.5.20 states:
Per the CDI specification, dependency injection is supported on
managed
beans. There are currently three ways for a class to become a managed
bean:
1. Being an EJB session bean component.
2. Being annotated with the @ManagedBean annotation.
3. Satisfying the conditions in Section 3.1 of the CDI specification.
Classes that satisfy at least one of these conditions will be eligible
for full
dependency injection support, as described in CDI.
and
Clearly, in the absence of any additional annotations, most component
classes
listed in Table EE.5-1 will not be managed beans. So as to make injection
support
more uniform across all component types, Java EE containers are required
to
support field or method injection (but not constructor injection) using
@javax.inject.Inject on all component classes listed in Table EE.5-1 when
the
containing archive is a bean archive.
Our interpretation of the above is that we definitely need to support
field injection of @Inject into @ManagedBean beans, and we also need to
support constructor injection
What are other's interpretation?
Regards,
Stephen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jsr-314-open-mirror/attachments/20100624/15fe6a7e/attachment-0002.html
More information about the jsr-314-open-mirror
mailing list