[cdi-dev] [JBoss JIRA] (CDI-277) Clarify inheritance behavior of observer methods

Arne Limburg (JIRA) jira-events at lists.jboss.org
Sat Oct 13 15:08:01 EDT 2012


    [ https://issues.jboss.org/browse/CDI-277?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12726224#comment-12726224 ] 

Arne Limburg commented on CDI-277:
----------------------------------

That leads to the inheritance issues. So which methods should be called in this scenario:
{code}
public class BeanA {

    private void observer1(@Observes Event1 event1) {
    }

    public void observer2(@Observes Event2 event2) {
    }

    private static void observer3(@Observes Event3 event3) {
    }

    public static void observer4(@Observes Event4 event4) {
    }
}

public class BeanB extends BeanA {

    private void observer1(@Observes Event1 event1) {
    }

    public void observer2(@Observes Event2 event2) {
    }

    private static void observer3(@Observes Event3 event3) {
    }

    public static void observer4(@Observes Event4 event4) {
    }
}
{code}

On event1 I would expect to be called:
observer1 of BeanA on an instance of BeanA
observer1 of BeanA on an instance of BeanB
observer1 of BeanB on an instance of BeanB

On event2 I would expect to be called:
observer2 of BeanA on an instance of BeanA
observer2 of BeanB on an instance of BeanB

On event3 I would expect to be called:
observer3 of BeanA
observer3 of BeanB

On event4 I would expect to be called:
observer4 of BeanA
observer4 of BeanB

right?
                
> Clarify inheritance behavior of observer methods
> ------------------------------------------------
>
>                 Key: CDI-277
>                 URL: https://issues.jboss.org/browse/CDI-277
>             Project: CDI Specification Issues
>          Issue Type: Clarification
>            Reporter: Arne Limburg
>
> Chapter 4.2 of the (1.0) spec misses a bullet point about inheritance of observer methods.
> Either
> - If X declares a non-static observer method x() then Y does inherit this method.
> or
> - If X declares a non-static observer method x() then Y does not inherit this method.
> (This behavior is different to what is defined in the Common Annotations for the Java Platform specification.)
> should be added.
> Don't know, what's right through...

--
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: http://www.atlassian.com/software/jira


More information about the cdi-dev mailing list