Interface ObserverMethod<T>
- Type Parameters:
T
- the event type
- All Superinterfaces:
Prioritized
Represents an observer method of an enabled bean. Defines everything the container needs to know about an observer method.
If a custom implementation of this interface does not override either notify(Object)
or
notify(EventContext)
, the container automatically detects the problem and treats it as a definition error.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionClass<?>
Obtains the class of the type that declares the observer method.Obtains the set of observed event qualifiers.Obtains the observed event type.default int
The priority that will be used by the container to determine the notification order in which event observer methods are invoked.Obtains the specifiedReception
for the observer method.Obtains the specifiedTransactionPhase
for the observer method.default boolean
isAsync()
Determines if this observer method is asynchronousdefault void
notify
(EventContext<T> eventContext) Calls the observer method, passing the given event context.default void
Calls the observer method, passing the given event object.
-
Field Details
-
DEFAULT_PRIORITY
static final int DEFAULT_PRIORITY- See Also:
-
-
Method Details
-
getBeanClass
Class<?> getBeanClass()Obtains the class of the type that declares the observer method.
- Returns:
- the defining class
-
getObservedType
Type getObservedType()Obtains the observed event type.- Returns:
- the observed event type
-
getObservedQualifiers
Set<Annotation> getObservedQualifiers()Obtains the set of observed event qualifiers.- Returns:
- the observed event qualifiers
-
getReception
Reception getReception()Obtains the specifiedReception
for the observer method. This indicates if the observer is conditional or not.- Returns:
- the
Reception
-
getTransactionPhase
TransactionPhase getTransactionPhase()Obtains the specifiedTransactionPhase
for the observer method.- Returns:
- the
TransactionPhase
-
getPriority
default int getPriority()The priority that will be used by the container to determine the notification order in which event observer methods are invoked.- Specified by:
getPriority
in interfacePrioritized
- Returns:
- The priority that will be used by the container to determine the notification order in which event observer methods are invoked.
- Since:
- 2.0
-
notify
Calls the observer method, passing the given event object.
The implementation of this method for a custom observer method is responsible for deciding whether to call the method if the
getReception()
returnsReception.IF_EXISTS
.- Parameters:
event
- the event object
-
notify
Calls the observer method, passing the given event context.The container should always call this method, but the default implementation delegates to
notify(Object)
.The implementation of this method for a custom observer method is responsible for deciding whether to call the method if the
getReception()
returnsReception.IF_EXISTS
.- Parameters:
eventContext
-EventContext
used to notify observers
-
isAsync
default boolean isAsync()Determines if this observer method is asynchronous
- Returns:
- returns true if the method is an asynchronous observer method (i.e. defined with
ObservesAsync
), otherwise returns false
-