2 Replies Latest reply on May 7, 2006 8:22 AM by pmuir

    Suggested enhancement to @Observer annotation

      The Seam events functionality in CVS is pretty useful. I prefer using the annotations over events.xml but I find the annotations less flexible.

      I would like to allow one method to observe multiple event types. How about adding an @Observers annotation that works like @Roles? Here is an an example:

      @Observers({
       @Observer("somethingChanged"),
       @Observer("somethingElseChanged")
      })
      public void refresh() {
       ...
      }
      


      This would make my code cleaner especially if I'm observing many event types.

      Another suggestion is to add a priority hint to the @Observer annotation. This could just be an arbitrary number (like a z-index) that allows Observer instances to be sorted, allowing methods observing the same event type to be fired in a sensible order. Here is an example:

      @Observer("somethingChanged", 0)
      public void meFirst() {
       ...
      }
      
      @Observer("somethingChanged", 100)
      public void meNext() {
       ...
      }
      


      I hope this makes sense, I'll add this to JIRA if you think so.