1 Reply Latest reply on May 10, 2011 4:39 AM by Christian Bauer

    Event observers, qualified or not

    Christian Bauer Master

      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. 


      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:




      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) { ... }