Annotation Interface EventListener


@Retention(RUNTIME) @Target(METHOD) @Documented public @interface EventListener
Used to annotate event listener methods. Methods should be public and take one parameter which is the event to be handled.

For example, the following class implements a simple event listener:

      public class TestListener {
        @EventListener
        public void onEvent(SampleEvent event) {
            System.out.println("Handled an event: " + event);
        }
    }
 
Since:
2.0
See Also:
  • Element Details

    • scope

      String scope
      Default:
      ""
    • order

      int order
      See EventPublisher.publish(Object) for details on processing event order.
      Returns:
      int used for ordering event listeners
      Default:
      0