diff --git a/api/src/main/java/jakarta/enterprise/inject/spi/ObserverMethod.java b/api/src/main/java/jakarta/enterprise/inject/spi/ObserverMethod.java index e8209698..228cca34 100644 --- a/api/src/main/java/jakarta/enterprise/inject/spi/ObserverMethod.java +++ b/api/src/main/java/jakarta/enterprise/inject/spi/ObserverMethod.java @@ -55,6 +55,16 @@ public interface ObserverMethod extends Prioritized { */ public Class getBeanClass(); + /** + *

+ * Obtains the {@linkplain Bean bean} that declares the observer method. + * For synthetic observers, the return value is undefined. + *

+ * + * @return the declaring {@linkplain Bean bean} + */ + public Bean getDeclaringBean(); + /** * Obtains the {@linkplain jakarta.enterprise.event observed event type}. * diff --git a/spec/src/main/asciidoc/core/spi_full.asciidoc b/spec/src/main/asciidoc/core/spi_full.asciidoc index fccaeab5..a88ac8e8 100644 --- a/spec/src/main/asciidoc/core/spi_full.asciidoc +++ b/spec/src/main/asciidoc/core/spi_full.asciidoc @@ -114,6 +114,7 @@ The interface `jakarta.enterprise.inject.spi.ObserverMethod` defines everything ---- public interface ObserverMethod extends Prioritized { public Class getBeanClass(); + public Bean getDeclaringBean(); public Type getObservedType(); public Set getObservedQualifiers(); public Reception getReception(); @@ -126,6 +127,7 @@ public interface ObserverMethod extends Prioritized { ---- * `getBeanClass()` returns the class of the type that declares the observer method. +* `getDeclaringBean()` returns the `Bean` object that declares the observer method. Return value is undefined for synthetic observers. * `getObservedType()` and `getObservedQualifiers()` return the observed event type and qualifiers. * `getReception()` returns `IF_EXISTS` for a conditional observer and `ALWAYS` otherwise. * `getTransactionPhase()` returns the appropriate transaction phase for a transactional observer method or `IN_PROGRESS` otherwise.