Skip navigation links
Red Hat JBoss Enterprise Application Platform 7.1.0.GA

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:

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:

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:

See Also:
javax.enterprise.inject, Observes, Event, Qualifier
Skip navigation links
Red Hat JBoss Enterprise Application Platform 7.1.0.GA

Copyright © 2017 JBoss by Red Hat. All rights reserved.