-
- Type Parameters:
T
- the type of the event object
public interface Event<T>
Allows the application to fire events of a particular type.
Beans fire events via an instance of the Event interface, which may be injected:
@Inject @Any Event<LoggedInEvent> loggedInEvent;
The fire() method accepts an event object:
public void login() { ... loggedInEvent.fire( new LoggedInEvent(user) ); }
Any combination of qualifiers may be specified at the injection point:
@Inject @Admin Event<LoggedInEvent> adminLoggedInEvent;
Or, the
@Any
qualifier may be used, allowing the application to specify qualifiers dynamically:@Inject @Any Event<LoggedInEvent> loggedInEvent;
For an injected Event:
- the specified type is the type parameter specified at the injection point, and
- the specified qualifiers are the qualifiers specified at the injection point.
- Author:
- Gavin King, Pete Muir, David Allen
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description void
fire(T event)
Fires an event with the specified qualifiers and notifies observers.Event<T>
select(Annotation... qualifiers)
Obtains a child Event for the given additional required qualifiers.<U extends T>
Event<U>select(Class<U> subtype, Annotation... qualifiers)
Obtains a child Event for the given required type and additional required qualifiers.<U extends T>
Event<U>select(TypeLiteral<U> subtype, Annotation... qualifiers)
Obtains a child Event for the given required type and additional required qualifiers.
-
-
-
Method Detail
-
fire
void fire(T event)
Fires an event with the specified qualifiers and notifies observers.
- Parameters:
event
- the event object- Throws:
IllegalArgumentException
- if the runtime type of the event object contains a type variableObserverException
- if a notified observer throws a checked exception, it will be wrapped and rethrown as an (unchecked)ObserverException
-
select
Event<T> select(Annotation... qualifiers)
Obtains a child Event for the given additional required qualifiers.
- Parameters:
qualifiers
- the additional specified qualifiers- Returns:
- the child Event
- Throws:
IllegalArgumentException
- if passed two instances of the same qualifier type, or an instance of an annotation that is not a qualifier type
-
select
<U extends T> Event<U> select(Class<U> subtype, Annotation... qualifiers)
Obtains a child Event for the given required type and additional required qualifiers.
- Type Parameters:
U
- the specified type- Parameters:
subtype
- aClass
representing the specified typequalifiers
- the additional specified qualifiers- Returns:
- the child Event
- Throws:
IllegalArgumentException
- if passed two instances of the same qualifier type, or an instance of an annotation that is not a qualifier type
-
select
<U extends T> Event<U> select(TypeLiteral<U> subtype, Annotation... qualifiers)
Obtains a child Event for the given required type and additional required qualifiers.
- Type Parameters:
U
- the specified type- Parameters:
subtype
- aTypeLiteral
representing the specified typequalifiers
- the additional specified qualifiers- Returns:
- the child Event
- Throws:
IllegalArgumentException
- if passed two instances of the same qualifier type, or an instance of an annotation that is not a qualifier type
-
-
Document created the 11/06/2005, last modified the 18/08/2025
Source of the printed document:https://www.gaudry.be/en/java-api-javaee-rf-javax/enterprise/event/event.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author of this site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.