Top Description Fields Methods
jakarta.enterprise.inject.spi

public Interface ObserverMethod<T>

extends Prioritized
Type Parameters
<T>
the event type
Imports
java.lang.annotation.Annotation, java.lang.reflect.Type, java.util.Set, jakarta.enterprise.event.Observes, .ObservesAsync, .Reception, .TransactionPhase

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.

Authors
Gavin King, David Allen, Mark Paluch, Antoine Sabot-Durand

Field Summary

Modifier and TypeField and Description
public static final int
DEFAULT_PRIORITY

The default observer priority

Method Summary

Modifier and TypeMethod and Description
public Class<?>

Returns:

the defining class
getBeanClass
()

Obtains the class of the type that declares the observer method.

public default Bean<?>

Returns:

the declaring bean
getDeclaringBean
()

Obtains the bean that declares the observer method.

public Set<Annotation>

Returns:

the observed event qualifiers
getObservedQualifiers
()

Obtains the set of observed event qualifiers.

public Type

Returns:

the observed event type
getObservedType
()

Obtains the observed event type.

public default int

Returns:

The priority that will be used by the container to determine the notification order in which event observer methods are invoked.
getPriority
()

Implements jakarta.enterprise.inject.spi.Prioritized.getPriority.

The priority that will be used by the container to determine the notification order in which event observer methods are invoked.

public Reception

Returns:

the Reception
getReception
()

Obtains the specified Reception for the observer method.

public TransactionPhase

Returns:

the TransactionPhase
getTransactionPhase
()

Obtains the specified TransactionPhase for the observer method.

public default boolean

Returns:

returns true if the method is an asynchronous observer method (i.e. defined with ObservesAsync), otherwise returns false
isAsync
()

Determines if this observer method is asynchronous

public default void
notify(T
the event object
event
)

Calls the observer method, passing the given event object.

public default void
notify(EventContext<T>
EventContext used to notify observers
eventContext
)

Calls the observer method, passing the given event context.

Field Detail

DEFAULT_PRIORITYback to summary
public static final int DEFAULT_PRIORITY

The default observer priority

Method Detail

getBeanClassback to summary
public Class<?> getBeanClass()

Obtains the class of the type that declares the observer method.

Returns:Class<?>

the defining class

getDeclaringBeanback to summary
public default Bean<?> getDeclaringBean()

Obtains the bean that declares the observer method. For synthetic observers, the return value is undefined.

For the sake of compatibility with existing custom ObserverMethod implementations, this method by default returns null.

Returns:Bean<?>

the declaring bean

Since
4.0
getObservedQualifiersback to summary
public Set<Annotation> getObservedQualifiers()

Obtains the set of observed event qualifiers.

Returns:Set<Annotation>

the observed event qualifiers

getObservedTypeback to summary
public Type getObservedType()

Obtains the observed event type.

Returns:Type

the observed event type

getPriorityback to summary
public default int getPriority()

Implements jakarta.enterprise.inject.spi.Prioritized.getPriority.

The priority that will be used by the container to determine the notification order in which event observer methods are invoked.

Returns:int

The priority that will be used by the container to determine the notification order in which event observer methods are invoked.

Annotations
@Override
Since
2.0
getReceptionback to summary
public Reception getReception()

Obtains the specified Reception for the observer method. This indicates if the observer is conditional or not.

Returns:Reception

the Reception

getTransactionPhaseback to summary
public TransactionPhase getTransactionPhase()

Obtains the specified TransactionPhase for the observer method.

Returns:TransactionPhase

the TransactionPhase

isAsyncback to summary
public default boolean isAsync()

Determines if this observer method is asynchronous

Returns:boolean

returns true if the method is an asynchronous observer method (i.e. defined with ObservesAsync), otherwise returns false

notifyback to summary
public default void notify(T event)

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() returns Reception#IF_EXISTS.

Parameters
event:T

the event object

notifyback to summary
public default void notify(EventContext<T> eventContext)

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() returns Reception#IF_EXISTS.

Parameters
eventContext:EventContext<T>

EventContext used to notify observers