Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-4

Need a way to provide ordering for Event observers

      There needs to be a way to specify some kind of ordering for Event observers.

      Understandably, this is somewhat counter-intuitive to the general concept of observing an event, but there is going to be need for this in an upcoming JBoss project. While it can be done manually, it might be nice to have a built-in API.

            [CDI-4] Need a way to provide ordering for Event observers

            Jozef Hartinger added a comment - Proposed changes to @Priority and ObserverMethod SPI: https://github.com/weld/api/blob/3.0.Alpha1/weld/src/main/java/org/jboss/weld/experimental/ExperimentalObserverMethod.java https://github.com/weld/api/blob/3.0.Alpha1/weld/src/main/java/org/jboss/weld/experimental/Priority.java

            Martin Kouba added a comment - - edited

            Actually, javax.annotation.Priority is not a part of the Java SE (only EE 7+), so it shouldn't be a big problem.

            Martin Kouba added a comment - - edited Actually, javax.annotation.Priority is not a part of the Java SE (only EE 7+), so it shouldn't be a big problem.

            Yes, that reminds me of javax.annotation.Resource. It got updated in Java EE 6 (it introduced the lookup() method) and we had to endorse the library for Java SE 6. So yes, there is a bit of tuning when you touch common code like Commons Annotation.

            Antonio Goncalves (Inactive) added a comment - Yes, that reminds me of javax.annotation.Resource . It got updated in Java EE 6 (it introduced the lookup() method) and we had to endorse the library for Java SE 6. So yes, there is a bit of tuning when you touch common code like Commons Annotation .

            agoncal Hm, so it woudn't work for Java 8 SE without some dependency tuning, right? I'm just pointing out there is a little complication...

            Martin Kouba added a comment - agoncal Hm, so it woudn't work for Java 8 SE without some dependency tuning, right? I'm just pointing out there is a little complication...

            martinkouba_jira There was a maintenance release during Java EE 7 for the JSR 250, it can be updated again on Java EE 8 if needed.

            Antonio Goncalves (Inactive) added a comment - martinkouba_jira There was a maintenance release during Java EE 7 for the JSR 250 , it can be updated again on Java EE 8 if needed.

            agoncal javax.annotation.Priority has @Target(value=TYPE) so we can't use it for observer methods

            Martin Kouba added a comment - agoncal javax.annotation.Priority has @Target(value=TYPE) so we can't use it for observer methods

            jporter@redhat.com] same unspecified behaviour as we have today for ALL observers

            Mark Struberg (Inactive) added a comment - jporter@redhat.com ] same unspecified behaviour as we have today for ALL observers

            If we have something at the same priority level, is it just unspecified behavior?

            Jason Porter added a comment - If we have something at the same priority level, is it just unspecified behavior?

            And now that we have @Priority, can't we just use it ?

            public class MyBean
            	public void myFirstObserverInPriority(@Observes @Priority(1000) MyEvent event) { ... }
            }
            
            public class MyBean
            	public void mySecondObserverInPriority(@Observes @Priority(42) MyEvent event) { ... }
            }
            

            Antonio Goncalves (Inactive) added a comment - And now that we have @Priority , can't we just use it ? public class MyBean public void myFirstObserverInPriority(@Observes @Priority(1000) MyEvent event) { ... } } public class MyBean public void mySecondObserverInPriority(@Observes @Priority(42) MyEvent event) { ... } }

            Fix issue title to just be about event observers. Defer

            Pete Muir (Inactive) added a comment - Fix issue title to just be about event observers. Defer

              asabotdu@redhat.com Antoine Sabot-Durand (Inactive)
              lincolnthree Lincoln Baxter III (Inactive)
              Votes:
              7 Vote for this issue
              Watchers:
              20 Start watching this issue

                Created:
                Updated:
                Resolved: