]
Jozef Hartinger closed CDI-238.
-------------------------------
Assignee: Jozef Hartinger
Fix Version/s: (was: 1.1.PFD)
Resolution: Cannot Reproduce Bug
This is actually clear in the spec.
Clarify enablement of a specialized bean
----------------------------------------
Key: CDI-238
URL:
https://issues.jboss.org/browse/CDI-238
Project: CDI Specification Issues
Issue Type: Clarification
Components: Concepts
Affects Versions: 1.1.EDR
Reporter: Jozef Hartinger
Assignee: Jozef Hartinger
Assume the following class
{code:JAVA}
public class X
{code}
and deployment structure:
{code}
+-application.ear
+-web1.war
+-web2.war
+-lib/
+-shared.jar
+-X.class
{code}
In addition, we assume the standard accessibility layout, where web archives are isolated
and both web archives have access to the shared library archive. Note that the beans.xml
file, which is present in web1.war, web2.war and shared.jar is omitted in deployment
structure diagrams.
The X bean is available for injection in both web1 and web2 applications.
Furthermore, let's assume that web1 introduces the following bean for its own
purpose:
{code:JAVA}
@Specializes
public class Y extends X
{code}
{code}
+-application.ear
+-web1.war
+-WEB-INF/
+-classes/
+-Y.class
+-web2.war
+-lib/
+-shared.jar
+-X.class
{code}
Now assume the following injection point:
{code:JAVA}
@Inject
X bean;
{code}
If the injection point belongs to a bean bundled within web1.war, it should be injected
with an instance of Y.
If the injection point belongs to a bean bundled within shared.jar, it should be injected
with an instance of X (and not Y).
If the injection point belongs to a bean bundled within web2.war, it should intuitively
be injected with X (because Y is not accessible). However, the specification says that:
{quote}
A bean is said to be enabled if it is not specialized by any other enabled bean, as
defined in Section 4.3, “Specialization”...
{quote}
which X in this case is. As a result, the X bean is not enabled and the injection point
would be unsatisfied if deployed within web2.war. This seems to be very counterintuitive.
The fact whether a given bean can/cannot be injected due to specialization should be
decided per module and not on the global enabled/disabled level.
The proposed fix is to make a bean available for injection in a given module
- if the bean is not specialized by another enabled bean or
- the bean is specialized by another enabled bean and the specializing bean is not
available for injection in the given module.
It should also be clarified if container lifecycle events that are only fired for enabled
beans (such ProcessBean and ProcessBeanAttributes) should or should not be fired for beans
which are specialized in a certain module but are not in another module.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: