<tt><font size=2>Sorry for the delayed response. &nbsp;This one fell off
my radar...</font></tt>
<br>
<br><tt><font size=2>&nbsp;&gt;From the EE6 spec, Section EE.5.20 states:
<br>
&gt;&gt; <br>
&gt;&gt; &nbsp; &nbsp; Per the CDI specification, dependency injection
is supported on managed <br>
&gt;&gt; beans. There are currently three ways for a class to become a
managed bean: <br>
...<br>
&gt;&gt; &nbsp;3. Satisfying the conditions in Section 3.1 of the CDI specification.
<br>
&gt;&gt; &nbsp; &nbsp; Classes that satisfy at least one of these conditions
will be eligible for <i>full </i></font></tt>
<br><tt><font size=2>&gt;&gt;<i> &nbsp; &nbsp; dependency injection support</i>,
as described in CDI. </font></tt>
<br>
<br><tt><font size=2>Section 3.1 of the 299 spec says:</font></tt>
<br><font size=2 face="Arial"><b>3.1.1. Which Java classes are managed
beans?</b></font>
<br><font size=2 face="Times New Roman">A top-level Java class is a managed
bean if it is defined to be a managed bean by any other Java EE specification,
or if it</font>
<br><font size=2 face="Times New Roman">meets all of the following conditions:</font>
<br><font size=2 face="Times New Roman">• It is not a non-static inner
class.</font>
<br><font size=2 face="Times New Roman">• It is a concrete class, or is
annotated </font><tt><font size=1>@Decorator</font></tt><font size=2 face="Times New Roman">.</font>
<br><font size=2 face="Times New Roman">• It is not annotated with an
EJB component-defining annotation or declared as an EJB bean class in </font><tt><font size=1>ejb-jar.xml</font></tt><font size=2 face="Times New Roman">.</font>
<br><font size=2 face="Times New Roman">• It does not implement </font><tt><font size=1>javax.enterprise.inject.spi.Extension</font></tt><font size=2 face="Times New Roman">.</font>
<br><font size=2 face="Times New Roman">• It has an appropriate constructor—either:</font>
<br><font size=2 face="Times New Roman">• the class has a constructor
with no parameters, or</font>
<br><font size=2 face="Times New Roman">• the class declares a constructor
annotated </font><tt><font size=1>@Inject</font></tt><font size=2 face="Times New Roman">.</font>
<br><font size=2 face="Times New Roman">All Java classes that meet these
conditions are managed beans and thus no special declaration is required
to define a managed</font>
<br><font size=2 face="Times New Roman">bean.</font>
<br>
<br><tt><font size=2>&gt;&gt;If you think about it, this makes sense. If
you are in a CDI enabled bean archive, then why would you be using JSF
managed beans. If you aren't in a CDI enabled bean archive, ctor injection
is certainly &gt;&gt;not required.</font></tt>
<br><tt><font size=2>I believe that you could be taking a current archive
that contains JSF managed beans, turn it into a BDA, and then want to use
ctor injection. &nbsp;Having to remove JSF annotations to get this to work
seems unwarranted, and a moot point if the language in Section 3.1 of CDI
says we should be supporting it. &nbsp;</font></tt>
<br>
<br><tt><font size=2>I am writing to the CDI EG to get further clarification.
I actually agree with your interpretation, but would still like to get
it strongly worded in the specs. &nbsp;The loose definition of managed
beans between all the specs is very confusing. &nbsp;</font></tt>
<br>
<br><font size=2 face="sans-serif">Regards,<br>
Stephen<br>
</font><font size=3><br>
</font><img src=cid:_1_07C3AF6C07C3A244004AB86885257770><font size=2 color=#6000a1 face="Tahoma"><b><br>
stephen kenna &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; ibm websphere architecture &amp; development</b></font>
<br>
<br>
<br><tt><font size=2><br>
On 24 Jun 2010, at 07:46, Roger Kitain wrote:<br>
<br>
&gt;&gt; Hi Stephan - <br>
&gt;&gt; <br>
&gt;&gt; We have an open issue in Mojarra to support @Inject into JSF Managed
Beans.<br>
<br>
&gt;I believe this is for field injection only.<br>
<br>
&gt; <br>
&gt; Thanks, Roger.<br>
&gt; <br>
&gt; On 6/24/10 10:42 AM, Stephen Kenna wrote:<br>
&gt;&gt; We have internally been discussing @Inject into @ManagedBeans
(should be the same for JSF Managed beans defined in the faces-config.xml).
<br>
&gt;&gt; <br>
&gt;&gt; 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>
&gt;&gt; <br>
&gt;&gt; We did some testing on Glassfish, and not only did constructor
injection not occur, but field injection did not occur either. &nbsp;(Field
injection is working on JBoss) <br>
&gt;&gt; <br>
&gt;&gt; My reading of JSR-299 &amp; the EE6 spec differs from this. <br>
&gt;&gt; <br>
&gt;&gt; &gt;From JSR299 Section 1.2.1: <br>
&gt;&gt; In the Java EE 6 environment, all component classes supporting
injection, as defined by the Java EE 6 platform specifica- <br>
&gt;&gt; tion, may inject beans via the dependency injection service. <br>
&gt;&gt; <br>
&gt;&gt; Or JSR299 Section 3.8: <br>
&gt;&gt; An injected field is a non-static, non-final field of a bean class,
or of any Java EE component class supporting injection. <br>
&gt;&gt; <br>
&gt;&gt; &gt;From the EE6 spec, Section EE.5.20 states: <br>
&gt;&gt; <br>
&gt;&gt; &nbsp; &nbsp; Per the CDI specification, dependency injection
is supported on managed <br>
&gt;&gt; beans. There are currently three ways for a class to become a
managed bean: <br>
&gt;&gt; &nbsp;1. Being an EJB session bean component. <br>
&gt;&gt; &nbsp;2. Being annotated with the @ManagedBean annotation. <br>
&gt;&gt; &nbsp;3. Satisfying the conditions in Section 3.1 of the CDI specification.
<br>
&gt;&gt; &nbsp; &nbsp; Classes that satisfy at least one of these conditions
will be eligible for full <br>
&gt;&gt; dependency injection support, as described in CDI. <br>
&gt;&gt; <br>
&gt;&gt; and <br>
&gt;&gt; <br>
&gt;&gt; &nbsp; &nbsp; &nbsp;Clearly, in the absence of any additional
annotations, most component classes <br>
&gt;&gt; listed in Table EE.5-1 will not be managed beans. So as to make
injection support <br>
&gt;&gt; more uniform across all component types, Java EE containers are
required to <br>
&gt;&gt; support field or method injection (but not constructor injection)
using <br>
&gt;&gt; @javax.inject.Inject on all component classes listed in Table
EE.5-1 when the <br>
&gt;&gt; containing archive is a bean archive. <br>
&gt;&gt; &nbsp; <br>
&gt;&gt; Our interpretation of the above is that we definitely need to
support field injection of @Inject into @ManagedBean beans,<br>
<br>
&gt;Yes, this is definitely clear :-)<br>
<br>
&gt;&gt; and we also need to support constructor injection <br>
<br>
&gt;I'm pretty you don't. The @ManagedBean which causes the JSF managed
bean container to get involved is *different* to the @ManagedBean which
the EE spec indicates should support &gt;(javax.faces.bean.ManagedBean
vs javax.annotation.Managed - and yes, IMO this is a crazy divergence,
and we did argue against it). Using this logic, there is *no way* for a
managed bean which lives in the &gt;JSF managed bean container to become
a managed bean as defined by EE.5.20, and thus support ctor injection.
So, JSF managed beans are just required to support field injection.<br>
<br>
&gt;This is what we check in the CDI TCK.<br>
<br>
&gt;If you think about it, this makes sense. If you are in a CDI enabled
bean archive, then why would you be using JSF managed beans. If you aren't
in a CDI enabled bean archive, ctor injection is certainly &gt;not required.<br>
<br>
&gt;HTH<br>
</font></tt>