[cdi-dev] [JBoss JIRA] Updated: (CDI-124) Clarify how the ObserverMethod interface should be used

Jozef Hartinger (JIRA) jira-events at lists.jboss.org
Thu Sep 22 07:40:26 EDT 2011


     [ https://issues.jboss.org/browse/CDI-124?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jozef Hartinger updated CDI-124:
--------------------------------

    Fix Version/s: 1.1 (Proposed)
                       (was: TBD)


> 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
>             Fix For: 1.1 (Proposed)
>
>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the cdi-dev mailing list