Annotation Interface EventListener


@Documented @Target(METHOD) @Retention(RUNTIME) public @interface EventListener
An annotation to mark a method in a class as a method listening for an event. An event method must not be static and take the event the method is listening to as it's first argument. More specific filtering can be done by providing a specific channel this event listener listens to. The event channel can be specified by when calling the event being listened to.

If an event listener is taking more than one argument, all other arguments except the event one will be requested from the parent injection layer. The layer can be given to the specified EventManager#registerListener methods. By default, the InjectionLayer.ext() layer is used.

All listeners (or in other words, all method annotated with this annotation) specified in a class will get registered when calling one of the EventManager#registerListener methods.

Since:
4.0
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The channel this event is listening to.
    Defines the priority of this event.
  • Element Details

    • channel

      String channel
      The channel this event is listening to. Defaults to * meaning that the listener listens to all channels.
      Returns:
      the channel this listener listens to.
      Default:
      "*"
    • order

      Defines the priority of this event. A lower priority means that the event is called earlier in the chain. A high priority is useful if the listener should set the final result of the event. Defaults to NORMAL.

      First priority to the last executed:

      1. FIRST
      2. EARLY
      3. NORMAL
      4. LATE
      5. LAST
      6. MONITOR
      Returns:
      the priority of the listener.
      Default:
      NORMAL