Annotation Type ObservesAsync


@Target(PARAMETER) @Retention(SOURCE) public @interface ObservesAsync
Identifies the event parameter of an asynchronous observer method. May be applied to a parameter of a method of a bean class.

  public void afterLogin(@ObservesAsync LoggedInEvent event) { ... }

An observer method is a non-abstract method of a managed bean class.

Each observer method must have exactly one event parameter, of the same type as the event type it observes. Event qualifiers may be declared by annotating the event parameter with Named or any qualifier annotations. When searching for observer methods for an event, the container considers the type and qualifiers of the event parameter.

If the event parameter does not explicitly declare any qualifier, the observer method observes events with no qualifier.

The event parameter type may contain a type variable or wildcard.

In addition to the event parameter, observer methods may declare additional parameters, which may declare qualifiers. These additional parameters are beans that will be injected when an event has occurred.


  public void afterLogin(@ObservesAsync LoggedInEvent event, @Manager User user, Logger log) { ... }

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    int
    The priority of the observe method
  • Element Details

    • priority

      int priority
      The priority of the observe method
      Default:
      1000