Skip to content

Commit

Permalink
Create an extra chapter "Context management for custom scopes"
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladicek committed Oct 21, 2021
1 parent af80858 commit 356ae28
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
28 changes: 16 additions & 12 deletions spec/src/main/asciidoc/core/scopescontexts.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
14 changes: 9 additions & 5 deletions spec/src/main/asciidoc/core/scopescontexts_full.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<builtin_contexts>>, 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}
Expand Down Expand Up @@ -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 <<custom_contexts>>, 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.

0 comments on commit 356ae28

Please sign in to comment.