1 Reply Latest reply on May 10, 2011 4:39 AM by christian.bauer

    Event observers, qualified or not

    christian.bauer

      The following two statements in the 1.0 spec apparently caused some confusion, section 10.2:


      An event is delivered to an observer method if:
      -     The observer method has all the event qualifiers. 
      



      10.2.3:


      Other, less specific, observers will also be notified of this event:
      
      public void afterDocumentUpdated(@Observes @Updated Document doc) { ... }
      public void afterDocumentEvent(@Observes Document doc) { ... }
      
      



      So which one is it? If you fire @Updated Document, will both methods be called or not?


      The confusion continues here:


      https://issues.jboss.org/browse/WELD-767


      https://issues.jboss.org/browse/WELD-454


      http://docs.jboss.org/weld/reference/1.1.0.Final/en-US/html_single/#events



      An observer method need not specify any event qualifiers—in this case it is interested in only unqualified events of a particular type.

      It seems to me like WELD-767 was wrong and the documentation change needs to be reverted. Instead a solution to exclude the less specific observer when a more specific event is fired would be:


      public void afterDocumentEvent(@Observes @Default Document doc) { ... }