users@glassfish.java.net

CDI's relationship to _at_ManagedBean

From: Laird Nelson <ljnelson_at_gmail.com>
Date: Mon, 11 Jun 2012 11:07:09 -0400

For those not breathlessly following
http://java.net/jira/browse/GLASSFISH-18793, GlassFish's integration
between JAX-RS, Managed Beans and CDI is puzzling.

Perhaps it would not be puzzling if there were a clear answer to these
questions:

Does a class annotated @ManagedBean that is NOT part of a CDI bean archive
"count" as a potential target for @Injections?

Consider a JAX-RS resource class that is not hosted within its "parent"
.war file, but is packaged instead inside an .ear file's lib directory.
 Must its "parent" .war file be a bean archive (i.e. contain
WEB-INF/beans.xml)? (In GlassFish 3.1.2 that .war file must be declared as
a bean archive for its JAX-RS resource classes that are actually packaged
apart from it to be valid CDI injection targets--and those JAX-RS resource
classes must NOT be packaged in bean archives themselves; this appears to
be a CDI specification violation)?

The CDI specification says in section 1.2.3, about its relationship to the
Managed Beans specification, that "the container performs dependency
injection on all managed bean instances, even those which are not
contextual instances." Which "managed beans" is this area of the
specification talking about? Java EE Managed Beans? Or CDI "managed
beans", which include just about everything, provided that you're in a bean
archive? (In GlassFish 3.1.2 a free-floating JAX-RS resource class must
NOT be packaged in a bean archive for CDI injection to occur, and MUST be
annotated @ManagedBean for CDI injection to occur. This also appears to be
a CDI specification violation.)

Hope all this archaeology is helpful to someone.

Best,
Laird

-- 
http://about.me/lairdnelson