<tt><font size=2>Sorry for the delayed response. This one fell off
my radar...</font></tt>
<br>
<br><tt><font size=2> >From the EE6 spec, Section EE.5.20 states:
<br>
>> <br>
>> Per the CDI specification, dependency injection
is supported on managed <br>
>> beans. There are currently three ways for a class to become a
managed bean: <br>
...<br>
>> 3. Satisfying the conditions in Section 3.1 of the CDI specification.
<br>
>> Classes that satisfy at least one of these conditions
will be eligible for <i>full </i></font></tt>
<br><tt><font size=2>>><i> 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>>>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 >>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. 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. </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. The loose definition of managed
beans between all the specs is very confusing. </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
ibm websphere architecture & development</b></font>
<br>
<br>
<br><tt><font size=2><br>
On 24 Jun 2010, at 07:46, Roger Kitain wrote:<br>
<br>
>> Hi Stephan - <br>
>> <br>
>> We have an open issue in Mojarra to support @Inject into JSF Managed
Beans.<br>
<br>
>I believe this is for field injection only.<br>
<br>
> <br>
> Thanks, Roger.<br>
> <br>
> On 6/24/10 10:42 AM, Stephen Kenna wrote:<br>
>> 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>
>> In the Java EE 6 environment, all component classes supporting
injection, as defined by the Java EE 6 platform specifica- <br>
>> tion, may inject beans via the dependency injection service. <br>
>> <br>
>> Or JSR299 Section 3.8: <br>
>> An injected field is a non-static, non-final field of a bean class,
or of any Java EE component class supporting injection. <br>
>> <br>
>> >From the EE6 spec, Section EE.5.20 states: <br>
>> <br>
>> Per the CDI specification, dependency injection
is supported on managed <br>
>> beans. There are currently three ways for a class to become a
managed bean: <br>
>> 1. Being an EJB session bean component. <br>
>> 2. Being annotated with the @ManagedBean annotation. <br>
>> 3. Satisfying the conditions in Section 3.1 of the CDI specification.
<br>
>> Classes that satisfy at least one of these conditions
will be eligible for full <br>
>> dependency injection support, as described in CDI. <br>
>> <br>
>> and <br>
>> <br>
>> Clearly, in the absence of any additional
annotations, most component classes <br>
>> listed in Table EE.5-1 will not be managed beans. So as to make
injection support <br>
>> more uniform across all component types, Java EE containers are
required to <br>
>> support field or method injection (but not constructor injection)
using <br>
>> @javax.inject.Inject on all component classes listed in Table
EE.5-1 when the <br>
>> containing archive is a bean archive. <br>
>> <br>
>> Our interpretation of the above is that we definitely need to
support field injection of @Inject into @ManagedBean beans,<br>
<br>
>Yes, this is definitely clear :-)<br>
<br>
>> and we also need to support constructor injection <br>
<br>
>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 >(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 >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>
>This is what we check in the CDI TCK.<br>
<br>
>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 >not required.<br>
<br>
>HTH<br>
</font></tt>