Skip to content

Instantly share code, notes, and snippets.

@mp911de
Created June 18, 2015 06:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mp911de/d4e2fd5d79416e659895 to your computer and use it in GitHub Desktop.
Prioritized Event Observers with CDI 2.0 (EDR1)
public class MyEventPayload {
}
public class PrioritizedObservers {
@Inject
private Event<MyEventPayload> event;
public void trigger(){
event.fire(new MyEventPayload());
}
public void observeBeforeOtherObservers(@Observes @Priority(Interceptor.Priority.APPLICATION - 1) MyEventPayload payload){
System.out.println("Notified before all other observers");
}
public void observeAfterOtherObservers(@Observes @Priority(Interceptor.Priority.APPLICATION + 501) MyEventPayload payload){
System.out.println("Notified after all other observers");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment