Skip to content

Commit

Permalink
Allow relaxing invoker lookup rules for asynchronous methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladicek committed Feb 20, 2024
1 parent 43a0f47 commit ebd14d4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spec/src/main/asciidoc/core/invokers.asciidoc
Expand Up @@ -215,6 +215,13 @@ Implementations are permitted to remember the identified beans and not repeat th
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.

This specification recognizes the existence of _asynchronous_ methods, where the action represented by the method does not always finish when the method returns; the _completion_ of the action is asynchronous to the method call.
Implementations are permitted (but not required) to provide an API that allows integrators to specify which target methods shall be considered asynchronous and how completion is propagated to the caller.
For asynchronous target methods, the requirement to destroy instances of `@Dependent` looked up beans is relaxed: the instances of `@Dependent` looked up beans need not be destroyed before `Invoker.invoke()` returns, it is instead the responsibility of the implementation and the integrator to ensure that they are destroyed at the right moment.
It is recommended that the instances of `@Dependent` looked up beans are destroyed after the asynchronous action completes and before the completion is propagated to the caller of `Invoker.invoke()`; if an asynchronous target method completes synchronously or throws synchronously, it is recommended that the instances of `@Dependent` looked up beans are destroyed before `invoke()` returns or rethrows the exception.

NOTE: This optional behavior may become a requirement in a future version of this specification.

The order in which instances of looked up beans are obtained during `Invoker.invoke()` in not specified.

If an exception is thrown when creating an instance of a looked up bean during `Invoker.invoke()`, the exception is rethrown.
Expand Down

0 comments on commit ebd14d4

Please sign in to comment.