Package javax. enterprise. event

Annotations and interfaces relating to events.

See: Description

Package javax.enterprise.event Description

Annotations and interfaces relating to events.

Beans may produce and consume events. Events allows beans to interact in a completely decoupled fashion, with no compile-time dependency between the interacting beans. Most importantly, it allows stateful beans in one architectural tier of the application to synchronize their internal state with state changes that occur in a different tier.

An event comprises:

  • A Java object, called the event object
  • A (possibly empty) set of instances of qualifier types, called the event qualifiers

The Event interface is used to fire events.

Event objects and event types

The event object acts as a payload, to propagate state from producer to consumer. An event object is an instance of a concrete Java class with no type variables.

The event types of the event include all superclasses and interfaces of the runtime class of the event object. An event type may not contain a type variable.

Event qualifiers

The event qualifiers act as topic selectors, allowing the consumer to narrow the set of events it observes. An event qualfier may be an instance of any qualifier type.

Observer methods

An observer method allows the application to receive and respond to event notifications. It acts as event consumer, observing events of a specific type, with a specific set of qualifiers. Any Java type may be observed by an observer method.

An observer method is a method of a bean class or extension with a parameter annotated @Observes.

An observer method will be notified of an event if:

  • the event object is assignable to the type observed by the observer method,
  • the observer method has all the event qualifiers of the event, and
  • either the event is not a container lifecycle event, or the observer method belongs to an extension.

If the observer method is a transactional observer method and there is a JTA transaction in progress when the event is fired, the observer method is notified during the appropriate transaction completion phase. Otherwise, the observer is notified when the event is fired.

The order in which observer methods are called is not defined, and so portable applications should not rely upon the order in which observers are called.

Observer methods may throw exceptions:

  • If the observer method is a transactional observer method, any exception is caught and logged by the container.
  • Otherwise, the exception aborts processing of the event. No other observer methods of that event will be called. The exception is rethrown. If the exception is a checked exception, it is wrapped and rethrown as an (unchecked) ObserverException.
See Also:
javax.enterprise.inject, Observes, Event, Qualifier

Traduction non disponible

Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.

Version en cache

21/08/2025 18:57:04 Cette version de la page est en cache (à la date du 21/08/2025 18:57:04) afin d'accélérer le traitement.
Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.

Document créé le 11/06/2005, dernière modification le 18/08/2025
Source du document imprimé : https://www.gaudry.be/java-api-javaee-rf-javax/enterprise/event/package-summary.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.

Références

  1. Consulter le document html Langue du document :fr Manuel PHP : https://docs.oracle.com, javax.enterprise.event (Java(TM) EE 7 Specification APIs)

Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.