Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify @Priority on producers #699

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion spec/src/main/asciidoc/core/injectionandresolution.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ 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.

Expand Down Expand Up @@ -111,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.

Expand Down