Skip to content

Commit

Permalink
avoid saying that argument lookup turns a target method parameter int…
Browse files Browse the repository at this point in the history
…o an injection point; this commit should be squashed
  • Loading branch information
Ladicek committed Feb 7, 2024
1 parent 7ce779e commit c366a90
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public interface InvokerBuilder<T> {
/**
* Enables lookup of the argument on given {@code position}.
*
* @param position zero-based argument position for which lookup is enabled
* @param position zero-based position of the target method parameter for which lookup should be enabled
* @return this builder
* @throws IllegalArgumentException if {@code position} is less than 0 or greater than
* or equal to the number of parameters declared by the target method
Expand Down
9 changes: 7 additions & 2 deletions spec/src/main/asciidoc/core/invokers.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,18 @@ public interface InvokerBuilder<T> {
When `withInstanceLookup()` is called on an invoker builder and the target method is not `static`, the `invoke()` method of the built invoker shall ignore the `instance` argument and instead obtain and use a contextual reference for the target bean and the bean type that declares the target method.
Calling `withInstanceLookup()` on an invoker builder for a `static` target method has no effect.

When `withArgumentLookup()` is called on an invoker builder, the `invoke()` method of the built invoker shall ignore the given element of the `arguments` array and instead obtain and use an injectable reference for an injection point that is the corresponding parameter of the target method.
When `withArgumentLookup()` is called on an invoker builder, the `invoke()` method of the built invoker shall ignore the given element of the `arguments` array and instead:

1. identify a bean according to the rules of typesafe resolution, as defined in <<performing_typesafe_resolution>>, where the required type is the declared type of the corresponding parameter of the target method and the required qualifiers are all qualifiers present on the parameter, resolving ambiguities according to <<unsatisfied_and_ambig_dependencies>>;
2. obtain and use a contextual reference for the identified bean and the declared type of the parameter.

Calling `withArgumentLookup()` with `position` less than 0 or greater than or equal to the number of parameters of the target method leads to an `IllegalArgumentException`.

In the following paragraphs, the beans whose instances shall be obtained by `Invoker.invoke()` as a result of calling `withInstanceLookup()` and `withArgumentLookup()` are called _looked up beans_.

During deployment validation, implementations are required to identify all looked up beans for all built invokers, according to the rules of typesafe resolution, as defined in <<performing_typesafe_resolution>>, resolving ambiguities according to <<unsatisfied_and_ambig_dependencies>>.
During deployment validation, implementations are required to identify all looked up beans for all built invokers, as described above.
It is a deployment problem if an attempt to identify a looked up bean results in an unsatisfied dependency or an ambiguous dependency that is not resolvable.
Implementations are permitted to remember the identified beans and not repeat the resolution process for each invocation of `Invoker.invoke()`.

All instances of `@Dependent` looked up beans obtained during `Invoker.invoke()` are destroyed before the `invoke()` method returns or throws.
The order in which the instances of `@Dependent` looked up beans are destroyed is not specified.
Expand Down

0 comments on commit c366a90

Please sign in to comment.