diff --git a/api/src/main/java/jakarta/enterprise/inject/spi/BeanManager.java b/api/src/main/java/jakarta/enterprise/inject/spi/BeanManager.java index d70548ba..498bcc9b 100644 --- a/api/src/main/java/jakarta/enterprise/inject/spi/BeanManager.java +++ b/api/src/main/java/jakarta/enterprise/inject/spi/BeanManager.java @@ -92,6 +92,22 @@ */ public interface BeanManager extends BeanContainer { + /** + *

+ * Obtains an injectable reference for a certain {@linkplain InjectionPoint injection point}. + *

+ * + * @param ij the target injection point + * @param ctx a {@link CreationalContext} that may be used to destroy any object with scope + * {@link Dependent} that is created + * @return the injectable reference + * @throws UnsatisfiedResolutionException if typesafe resolution results in an unsatisfied dependency + * @throws AmbiguousResolutionException typesafe resolution results in an unresolvable ambiguous dependency + * @throws IllegalStateException if called during application initialization, before the {@link AfterDeploymentValidation} + * event is fired. + */ + Object getInjectableReference(InjectionPoint ij, CreationalContext ctx); + /** * Returns the {@link PassivationCapable} bean with the given identifier. * @@ -121,24 +137,6 @@ public interface BeanManager extends BeanContainer { */ public void validate(InjectionPoint injectionPoint); - /** - * Return an ordered set of {@linkplain ObserverMethod observer methods} for an event. - * - * Note that when called during invocation of an {@link AfterBeanDiscovery} event observer, - * this method will only return observers discovered by the container before the {@link AfterBeanDiscovery} event is fired. - * - * @param the type of the event - * @param event the event object - * @param qualifiers the event qualifiers - * @return the resulting set of {@linkplain ObserverMethod observer methods} - * @throws IllegalArgumentException if the runtime type of the event object contains a type variable - * @throws IllegalArgumentException if two instances of the same non repeating qualifier type are given - * @throws IllegalArgumentException if an instance of an annotation that is not a qualifier type is given - * @throws IllegalStateException if called during application initialization, before the {@link AfterBeanDiscovery} - * event is fired. - */ - public Set> resolveObserverMethods(T event, Annotation... qualifiers); - /** * Return an ordered list of {@linkplain Decorator decorators} for a set of bean types and a set of qualifiers and which are * enabled in the module or library containing the class into which the BeanManager was injected or the Java EE @@ -423,19 +421,4 @@ public Bean createBean(BeanAttributes attributes, Class beanClass, */ InterceptionFactory createInterceptionFactory(CreationalContext ctx, Class clazz); - /** - *

- * Obtains an injectable reference for a certain {@linkplain InjectionPoint injection point}. - *

- * - * @param ij the target injection point - * @param ctx a {@link CreationalContext} that may be used to destroy any object with scope - * {@link Dependent} that is created - * @return the injectable reference - * @throws UnsatisfiedResolutionException if typesafe resolution results in an unsatisfied dependency - * @throws AmbiguousResolutionException typesafe resolution results in an unresolvable ambiguous dependency - * @throws IllegalStateException if called during application initialization, before the {@link AfterDeploymentValidation} - * event is fired. - */ - Object getInjectableReference(InjectionPoint ij, CreationalContext ctx); } diff --git a/spec/src/main/asciidoc/core/beanmanager_lite.asciidoc b/spec/src/main/asciidoc/core/beanmanager_lite.asciidoc index 07ecc51c..532efd19 100644 --- a/spec/src/main/asciidoc/core/beanmanager_lite.asciidoc +++ b/spec/src/main/asciidoc/core/beanmanager_lite.asciidoc @@ -90,24 +90,6 @@ The third parameter is an instance of `CreationalContext` that may be used to de If the given type is not a bean type of the given bean, an `IllegalArgumentException` is thrown. -[[bm_obtain_injectable_reference]] - -==== Obtaining an injectable reference - -The method `BeanContainer.getInjectableReference()` returns an injectable reference for a given injection point, as defined in <>. - -[source, java] ----- -public Object getInjectableReference(InjectionPoint ij, CreationalContext ctx); ----- - -The first parameter represents the target injection point. -The second parameter is an instance of `CreationalContext` that may be used to destroy any object with scope `@Dependent` that is created. - -If typesafe resolution results in an unsatisfied dependency, the container must throw an `UnsatisfiedResolutionException`. If typesafe resolution results in an unresolvable ambiguous dependency, the container must throw an `AmbiguousResolutionException`. - -Implementations of `Bean` usually maintain a reference to an instance of `BeanContainer`. When the `Bean` implementation performs dependency injection, it must obtain the contextual instances to inject by calling `BeanContainer.getInjectableReference()`, passing an instance of `InjectionPoint` that represents the injection point and the instance of `CreationalContext` that was passed to `Bean.create()`. - [[bm_obtain_creationalcontext]] ==== Obtaining a `CreationalContext` diff --git a/spec/src/main/asciidoc/core/spi_full.asciidoc b/spec/src/main/asciidoc/core/spi_full.asciidoc index d58c81ca..6d5e04b2 100644 --- a/spec/src/main/asciidoc/core/spi_full.asciidoc +++ b/spec/src/main/asciidoc/core/spi_full.asciidoc @@ -256,14 +256,27 @@ A portable extension or other object may obtain a reference to the current conta `CDI.getBeanManager()` and `CDI.getBeanContainer()` may be called at any time after the container fires the `BeforeBeanDiscovery` container lifecycle event until the container fires the `BeforeShutdown` container lifecycle event. If methods on `CDI` are called at any other time, non-portable behavior results. -[[bm_obtain_injectable_reference_full]] +[[bm_obtain_injectable_reference]] -==== Obtaining an injectable reference in {cdi_full} +==== Obtaining an injectable reference -In addition to rules defined in <>, the following rules apply. +The method `BeanManager.getInjectableReference()` returns an injectable reference for a given injection point, as defined in <>. + +[source, java] +---- +public Object getInjectableReference(InjectionPoint ij, CreationalContext ctx); +---- + +The first parameter represents the target injection point. +The second parameter is an instance of `CreationalContext` that may be used to destroy any object with scope `@Dependent` that is created. If the `InjectionPoint` represents a decorator delegate injection point, `getInjectableReference()` returns a delegate, as defined in <>. +If typesafe resolution results in an unsatisfied dependency, the container must throw an `UnsatisfiedResolutionException`. If typesafe resolution results in an unresolvable ambiguous dependency, the container must throw an `AmbiguousResolutionException`. + +Implementations of `Bean` usually maintain a reference to an instance of `BeanManager`. When the `Bean` implementation performs dependency injection, it must obtain the contextual instances to inject by calling `BeanManager.getInjectableReference()`, passing an instance of `InjectionPoint` that represents the injection point and the instance of `CreationalContext` that was passed to `Bean.create()`. + + [[bm_obtain_unmanaged_instance]] ==== Obtaining non-contextual instance