From 2b339e2829af88d17ce966aa4ab324001991b751 Mon Sep 17 00:00:00 2001 From: Ladislav Thon Date: Wed, 24 May 2023 17:14:06 +0200 Subject: [PATCH 1/2] Specify @Priority on producers --- spec/src/main/asciidoc/core/injectionandresolution.asciidoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/src/main/asciidoc/core/injectionandresolution.asciidoc b/spec/src/main/asciidoc/core/injectionandresolution.asciidoc index e744e274..9ef8c67a 100644 --- a/spec/src/main/asciidoc/core/injectionandresolution.asciidoc +++ b/spec/src/main/asciidoc/core/injectionandresolution.asciidoc @@ -45,9 +45,13 @@ An alternative is not available for injection, lookup or name resolution to clas An alternative may be given a priority for the application: * by placing the `@Priority` annotation on the bean class of a managed bean, or +* by placing the `@Priority` annotation on the producer method, field or resource, or * by placing the `@Priority` annotation on the bean class that declares the producer method, field or resource, or * by placing the `@Priority` annotation on a stereotype that is applied to the bean class, producer method or producer field. +To determine the priority of a producer method or field, the `@Priority` annotation on the producer method or field is considered first. +If the producer method or field does not declare the `@Priority` annotation, the `@Priority` annotation declared on the bean class is used. + [[enablement]] ==== Enabled and disabled beans From f324670f5a505919a7084f2412f69aa9accbadde Mon Sep 17 00:00:00 2001 From: Ladislav Thon Date: Fri, 10 Nov 2023 15:31:22 +0100 Subject: [PATCH 2/2] WIP clarification, will be squashed --- .../asciidoc/core/injectionandresolution.asciidoc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/spec/src/main/asciidoc/core/injectionandresolution.asciidoc b/spec/src/main/asciidoc/core/injectionandresolution.asciidoc index 9ef8c67a..6b8560d9 100644 --- a/spec/src/main/asciidoc/core/injectionandresolution.asciidoc +++ b/spec/src/main/asciidoc/core/injectionandresolution.asciidoc @@ -49,9 +49,6 @@ An alternative may be given a priority for the application: * by placing the `@Priority` annotation on the bean class that declares the producer method, field or resource, or * by placing the `@Priority` annotation on a stereotype that is applied to the bean class, producer method or producer field. -To determine the priority of a producer method or field, the `@Priority` annotation on the producer method or field is considered first. -If the producer method or field does not declare the `@Priority` annotation, the `@Priority` annotation declared on the bean class is used. - [[enablement]] ==== Enabled and disabled beans @@ -115,9 +112,18 @@ The container eliminates all eligible beans that are not alternatives, except fo If: * there is exactly one bean remaining, the container will select this bean, and the ambiguous dependency is called resolvable. -* all the beans left are alternatives with a priority, or producer methods or fields of beans that are alternatives with a priority, then the container will determine the highest priority value, and eliminate all beans, except for alternatives with the highest priority and producer methods and fields of alternatives with the highest priority value. +* all the beans left are alternatives with a priority, or producer methods or fields of beans that are alternatives with a priority, then the container will determine the highest priority value and eliminate all beans, except for: ++ +-- +** alternatives with the highest priority value, +** producer methods and fields of alternatives, where either the producer method or field has the highest priority value, or the declaring alternative has the highest priority value. +-- ++ If there is exactly one bean remaining, the container will select this bean, and the ambiguous dependency is called resolvable. +For the purpose of determining the priority of any producer method or field during ambiguity resolution, the priority of the producer method or field is considered first. +If the producer method or field does not have a priority, the priority of the managed bean that declares the producer method or field is used. + The container must validate all injection points of all enabled beans, all observer methods and all disposer methods when the application is initialized to ensure that there are no unsatisfied or unresolvable ambiguous dependencies. If an unsatisfied or unresolvable ambiguous dependency exists, the container automatically detects the problem and treats it as a deployment problem.