From 356ae28b1ae6897f61b3aa3c3f71508e521446a1 Mon Sep 17 00:00:00 2001 From: Ladislav Thon Date: Thu, 21 Oct 2021 15:41:42 +0200 Subject: [PATCH] Create an extra chapter "Context management for custom scopes" --- .../asciidoc/core/scopescontexts.asciidoc | 28 +++++++++++-------- .../core/scopescontexts_full.asciidoc | 14 ++++++---- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/spec/src/main/asciidoc/core/scopescontexts.asciidoc b/spec/src/main/asciidoc/core/scopescontexts.asciidoc index c80b1761..e7095426 100644 --- a/spec/src/main/asciidoc/core/scopescontexts.asciidoc +++ b/spec/src/main/asciidoc/core/scopescontexts.asciidoc @@ -357,18 +357,6 @@ These implementations depend on the platform the container is running. The context associated with a built-in normal scope propagates across local, synchronous Java method calls. The context does not propagate across remote method invocations or to asynchronous processes. -Custom context implementations are encouraged to synchronously fire: - -* an event with qualifier `@Initialized(X.class)` when a custom context is initialized, i.e. ready for use, -* an event with qualifier `@BeforeDestroyed(X.class)` when a custom context is about to be destroyed, i.e. before the actual destruction, -* an event with qualifier `@Destroyed(X.class)` when a custom context is destroyed, i.e. after the actual destruction, - -where `X` is the scope type associated with the context. - -A suitable event payload should be chosen. - -A build compatible extensions may not define custom context class for any of the built-in scopes. - [[request_context]] ==== Request context lifecycle @@ -404,3 +392,19 @@ The _application context_ is provided by a built-in context object for the built An event with qualifier `@Initialized(ApplicationScoped.class)` is synchronously fired when the application context is initialized. An event with qualifier `@BeforeDestroyed(ApplicationScoped.class)` is synchronously fired when the application context is about to be destroyed, i.e. before the actual destruction. An event with qualifier `@Destroyed(ApplicationScoped.class)` is synchronously fired when the application context is destroyed, i.e. after the actual destruction. + +[[custom_contexts]] + +=== Context management for custom scopes + +Custom context implementations are encouraged to synchronously fire: + +* an event with qualifier `@Initialized(X.class)` when a custom context is initialized, i.e. ready for use, +* an event with qualifier `@BeforeDestroyed(X.class)` when a custom context is about to be destroyed, i.e. before the actual destruction, +* an event with qualifier `@Destroyed(X.class)` when a custom context is destroyed, i.e. after the actual destruction, + +where `X` is the scope type associated with the context. + +A suitable event payload should be chosen. + +Build compatible extensions may define custom context classes for custom scopes, but they may not define custom context classes for built-in scopes. diff --git a/spec/src/main/asciidoc/core/scopescontexts_full.asciidoc b/spec/src/main/asciidoc/core/scopescontexts_full.asciidoc index a372e504..efdc187b 100644 --- a/spec/src/main/asciidoc/core/scopescontexts_full.asciidoc +++ b/spec/src/main/asciidoc/core/scopescontexts_full.asciidoc @@ -156,11 +156,6 @@ If a managed bean which declares a passivating scope type, has a decorator or in === Context management for built-in scopes in {cdi_full} -In addition to rules defined in <>, the following rule applies. - -A portable extension may define a custom context object for any or all of the built-in scopes. -For example, a remoting framework might provide a request context object for the built-in request scope. - [[session_context_full]] ==== Session context lifecycle in {cdi_full} @@ -209,3 +204,12 @@ If `end()` is called, and the current conversation is marked transient, an `Ille If `begin()` is called, and the current conversation is already marked long-running, an `IllegalStateException` is thrown. If `begin()` is called with an explicit conversation identifier, and a long-running conversation with that identifier already exists, an `IllegalArgumentException` is thrown. + +[[custom_contexts_full]] + +=== Context management for custom scopes in {cdi_full} + +In addition to rules defined in <>, the following rule applies. + +A portable extension may define a custom context object for built-in scopes and custom scopes. +For example, a remoting framework might provide a request context object for the built-in request scope.