I think the problem should be rephrased, not for the purpose of philosophical consistency,
but because I believe that it changes the nature of the problem.
"Web beans" does not need to support EE resource injection since EE container
already do. Again, this spec is in the business of defining new services, not new
If we are in agreement (and I thought this was already assumed by the "removal of
contract" thread?) that these services are going to be integrated with the container,
pluggable, then the container already knows how to name, inject and locate resources. That
What is not well-defined is how to specify the service parameters for the services that
spec does define (scoping, binding, etc.) of an injected resource/component. So option 1
would discuss how the scope, binding, etc could be overridden on the component when the
A couple of comments to the two options:
1. Refs in EE are currently scoped to the component, not the module, so the validation is
not nearly as bad as having to look at the entire module. This is a better option and
the most sense for integration with the platform.
2. EE 6 is in fact defining the global naming rules for components via the mapped name,
so there could be a portable way of correlating the duplicate entries. (I still don't
the duplication, though, and much prefer option 1.)
I would like to see all of the EE injection be in the same spec, meaning that existing
EE resource injection would transition from its definition in the EE document to being in
one (if injection is to be a primary service defined and offered by this spec). All
should be consistently defined, explained and implemented.
From: Gavin King [mailto:email@example.com]
Sent: Monday, January 05, 2009 9:11 PM
To: Java Community Process JSR #299 Expert List; Michael Keith; Scott
Ferguson; Matt Drees; WebBeans
Subject: Java EE resource injection
Folks, it's time to address the problem of generalized Java EE
Web Beans needs to support injection of the following kinds of things:
* EE resources (e.g. JDBC datasources, etc)
* remote EJB references
* web service references
I believe we can treat all three as essentially the same kind of thing
in the spec. Let's call it a "EE resource reference", or whatever.
It's a new "kind" of Web Bean in Chapter 3. This functionality should
not impact any other part of the specification.
(An additional complication is that we need to unify the current
notion of a "JMS endpoint" with this functionality. I don't believe
that this is a difficult problem, we just need to make it a special
case of a "EE resource reference", that supports additional
I see two possible paths we could go down here:
The spec could simply say that for every "EE resource reference"
defined in web.xml or ejb-jar.xml, that a Web Bean exists with
deployment type @Production and no name. The scope and binding types
of this Web Bean have the usual defaults (@Depenent, @Current), but
these may be specified explicitly in web.xml or ejb-jar.xml:
The lifecycle of this Web Bean would be super-simple:
* Bean.create() would be equivalent to a JNDI lookup for the resource
* Bean.destroy() would simply discard the reference
There is just one problem with this approach: EE resource references
are by nature scoped to a particular EE module, whereas this is not
naturally the case for Web Beans (which are naturally EAR scoped). I
don't believe this is a really big problem but we would need to
institute an additional layer of validation to ensure that injection
points that refer to an EE resource are in the same module as the
resource ref declaration. This would be a new section in the spec, but
I don't believe it is difficult to write.
The second option would be to require explicit declaration of the
resource in web-beans.xml, thus making them an EAR-global declaration.
There are a couple of major problems with this:
* resources must be declared twice, in different places
* the two declarations are correlated via a global JNDI name, which:
- is still not really a well-defined construct in the EE spec
- cannot be properly validated at development time
Therefore I strongly prefer Option 1.