]
Pete Muir resolved CDI-124.
---------------------------
Fix Version/s: 1.1.PRD
(was: 1.1 (Proposed))
Resolution: Done
Clarify how the ObserverMethod interface should be used
-------------------------------------------------------
Key: CDI-124
URL:
https://issues.jboss.org/browse/CDI-124
Project: CDI Specification Issues
Issue Type: Clarification
Components: Events
Affects Versions: 1.0
Reporter: Jozef Hartinger
Assignee: Pete Muir
Fix For: 1.1.PRD
The CDI specification (10.5) says:
"For a custom implementation of the ObserverMethod interface defined in Section
11.1.3, "The ObserverMethod interface",
the container must call getReception() and getTransactionPhase() to determine if the
observer method is a conditional
or transactional observer method, and notify() to invoke the method."
However, calling ObserverMethod.getReception() is useless.
An ObserverMethod implementation can be registered by an portable extension via the
AfterBeanDiscovery event. The observer method may or may not be hosted by a CDI bean:
a) A portable extension adds a different way of declaring an observer method on a CDI
bean (e.g. using a different annotation like @Listens, or allowing a different method
signature)
b) A portable extension allows CDI observer methods to be registered on non-CDI beans
(e.g. on a Spring Bean)
In both cases, the container is not able find out if an instance of the hosting component
has been created already - it does not know the hosting bean in (a) and it obviously does
not know anything about the Spring bean (b).
Therefore, if the observer method is conditional (ObserverMethod.getReception() returns
IF_EXISTS), the container cannot decide whether it should invoke the observer method since
it has no way of finding out whether the underlying instance exists or not.
As a result, the container has to invoke ObserverMethod.notify() anyway. That's why I
consider ObserverMethod.getReception() useless.
To fix the problem, I think that the responsibility of deciding whether to invoke a
conditional observer method should be shifted from container to the ObserverMethod
implementation.
--
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: