From 0b8a36f33f600636015dc05f52751078ae758ea4 Mon Sep 17 00:00:00 2001 From: Ladislav Thon Date: Thu, 8 Feb 2024 10:23:20 +0100 Subject: [PATCH] allow lifecycle extension of @Dependent looked up beans in implementation-defined manner --- spec/src/main/asciidoc/core/invokers.asciidoc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/src/main/asciidoc/core/invokers.asciidoc b/spec/src/main/asciidoc/core/invokers.asciidoc index 1ab799b9..02160dcb 100644 --- a/spec/src/main/asciidoc/core/invokers.asciidoc +++ b/spec/src/main/asciidoc/core/invokers.asciidoc @@ -201,6 +201,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. +Implementations are permitted to extend the lifecycle of `@Dependent` looked up beans when they can conclusively determine that code called by the target method is capable of using the instances after the method returns. +Such lifecycle extension must not be infinite; the instances of `@Dependent` looked up beans must eventually be destroyed. +Implementations that do this must document the conditions under which such lifecycle extension applies and when the destruction happens. + +NOTE: It is expected that implementations that feature direct support for asynchronous programming will extend the lifecycle of `@Dependent` looked up beans until the asynchronous action started by the target method completes. +An "asynchronous" target method is typically recognized by return type, such as `CompletionStage` or `CompletableFuture`, or by presence of a special parameter, such as `AsyncResponse` in Jakarta REST. + 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.