<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Stephan - <br>
<br>
We have an open issue in Mojarra to support @Inject into JSF Managed
Beans.<br>
<br>
Thanks, Roger.<br>
<br>
On 6/24/10 10:42 AM, Stephen Kenna wrote:
<blockquote
cite="mid:OF446D2D89.56A60BDC-ON8725774C.004E9F84-8525774C.0050C524@us.ibm.com"
type="cite">
<meta http-equiv="Context-Type" content="text/html; charset=US-ASCII">
We have internally been discussing @Inject
into @ManagedBeans (should be the same for JSF Managed beans defined in
the faces-config.xml). <br>
<br>
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).
<br>
<br>
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) <br>
<br>
My reading of JSR-299 & the EE6
spec differs from this. <br>
<br>
>From JSR299 Section 1.2.1: <br>
<i>In the Java EE 6 environment, all
component classes supporting injection, as defined by the Java EE 6
platform
specifica-</i> <br>
<i>tion, may inject beans via the dependency
injection service.</i> <br>
<br>
Or JSR299 Section 3.8: <br>
<i>An injected field is a non-static,
non-final field of a bean class, or of any Java EE component class
supporting
injection.</i> <br>
<br>
>From the EE6 spec, Section EE.5.20 states: <br>
<br>
<i> Per the CDI specification,
dependency injection is supported on managed</i> <br>
<i>beans. There are currently three
ways for a class to become a managed bean:</i> <br>
<i> 1. Being an EJB session bean
component.</i> <br>
<i> 2. Being annotated with the
@ManagedBean annotation.</i> <br>
<i> 3. Satisfying the conditions
in Section 3.1 of the CDI specification.</i> <br>
<i> Classes that satisfy
at least one of these conditions will be eligible for full</i> <br>
<i>dependency injection support, as
described in CDI.</i> <br>
<br>
and <br>
<br>
<i>Clearly, in the
absence of any additional annotations, most component classes</i> <br>
<i>listed in Table EE.5-1 will not be
managed beans. So as to make injection support</i> <br>
<i>more uniform across all component
types, Java EE containers are required to</i> <br>
<i>support field or method injection
(but not constructor injection) using</i> <br>
<i>@javax.inject.Inject on all component
classes listed in Table EE.5-1 when the</i> <br>
<i>containing archive is a bean archive.</i> <br>
<i> </i> <br>
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 <br>
<br>
What are other's interpretation? <br>
<br>
<br>
Regards,<br>
Stephen<br>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-abbreviated" href="mailto:roger.kitain@oracle.com">roger.kitain@oracle.com</a>
<a class="moz-txt-link-freetext" href="https://twitter.com/rogerk09">https://twitter.com/rogerk09</a>
<a class="moz-txt-link-freetext" href="http://www.java.net/blogs/rogerk">http://www.java.net/blogs/rogerk</a>
</pre>
</body>
</html>