Skip to content

Commit

Permalink
Attempt to make the Full part more readable - merge decorator limitat…
Browse files Browse the repository at this point in the history
…ions into one chapter. Add multiple notions of Full - specific rules cak to original chapters and note that this behaviour is not in Lite.
  • Loading branch information
manovotn committed May 20, 2021
1 parent e70f5c0 commit 8f869d2
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 131 deletions.
2 changes: 0 additions & 2 deletions spec/src/main/asciidoc/cdi-spec.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ include::core/packagingdeployment_lite.asciidoc[]

include::core/definition_full.asciidoc[]

include::core/implementation_full.adoc[]

include::core/inheritance_full.asciidoc[]

include::core/injectionandresolution_full.asciidoc[]
Expand Down
27 changes: 27 additions & 0 deletions spec/src/main/asciidoc/core/decorators.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ If a decorator declares any scope other than `@Dependent`, the container automat
==== Declaring a decorator

A decorator is declared by annotating the bean class with the `@jakarta.decorator.Decorator` stereotype.
{cdi_full} provides this stereotype as a built-in stereotype in addition to other stereotypes defined in <<builtin_stereotypes>>.

[source, java]
----
Expand Down Expand Up @@ -228,3 +229,29 @@ The container intercepts the delegate invocation and searches for the first deco
If no such decorator exists, the container invokes the business method of the intercepted instance.
Otherwise, the container calls the method of the decorator.

[[decorator_additional_rules]]

=== Additional decorator rules

This chapter congregates various rules and limitations that apply to decorators in regard to other chapters of the specification.

==== Bean names

In addition to rules defined in <<beans_with_no_name>>, if a decorator has a name, non-portable behavior results.

==== Declaring alternatives

In addition to rules defined in <<declaring_alternative>>, if a decorator is an alternative, non-portable behavior results.

=== Managed beans

In addition to rules defined in <<managed_beans>>, if the bean class of a managed bean is annotated with both `@Interceptor` and `@Decorator`, the container automatically detects the problem and treats it as a definition error.

=== Producer and disposer methods

Decorators may not declare producer methods or fields.
If a decorator has a method or a field annotated `@Produces`, the container automatically detects the problem and treats it as a definition error.

Decorators may not declare disposer methods.
If a decorator has a method annotated `@Disposes`, the container automatically detects the problem and treats it as a definition error.

8 changes: 8 additions & 0 deletions spec/src/main/asciidoc/core/definition.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ The bean developer may also create interceptors or reuse existing interceptors.
The interceptor bindings of a bean determine which interceptors will be applied at runtime.
Interceptors are defined by Jakarta EE interceptors specification, and interceptor bindings are specified in <<interceptors>>.

When running in {cdi_full}, the bean developer may also create decorators or reuse existing decorators as defined in <<decorators>>.

[[capabilities]]

=== Functionality provided by the container to the bean
Expand All @@ -41,6 +43,10 @@ A bean is provided by the container with the following capabilities:
* method interception, callback interception, as defined in <<interceptors>>, and
* event notification, as defined in <<events>>.

When running {cdi_full}, the container has to also provide the following capabilities:

* method decoration, as defined in <<decorators>>


[[bean_types]]

Expand Down Expand Up @@ -207,6 +213,8 @@ An injection point may even specify multiple qualifiers.

Qualifier types are also used as event selectors by event consumers, as defined in <<events>>.

In {cdi_full} qualifier types are also used to bind decorators to beans, as specified in <<decorators>>.

[[builtin_qualifiers]]

==== Built-in qualifier types
Expand Down
65 changes: 5 additions & 60 deletions spec/src/main/asciidoc/core/definition_full.asciidoc
Original file line number Diff line number Diff line change
@@ -1,80 +1,25 @@
[[concepts_full]]

CDI Full contains all the functionality defined in {cdi_lite} and adds some more features such as decorators or conversation scope which are described in following paragraphs.

== Extended Concepts for {cdi_full}

When running in {cdi_full}, beans must extend their capabilities defined in <<concepts>>, by providing these additional capabilities:

The bean developer may also create decorators or reuse existing decorators.
The bean types and qualifiers of a bean determine which decorators will be applied at runtime.
Decorators are defined in <<decorators>>.

[[capabilities_full]]

=== Functionality provided by the container to the bean in {cdi_full}

When running in {cdi_full}, the container must extend the capabilities defined in <<capabilities>>, by providing an additional capability:

* method decoration, as defined in <<decorators>>

[[qualifiers_full]]

=== Qualifiers in {cdi_full}

In {cdi_full} qualifier types are also used to bind decorators to beans, as specified in <<decorators>>.
CDI Full contains all the functionality defined in {cdi_lite} and adds some additional features such as decorators or conversation scope.
Some of these concepts were briefly mentioned in the previous {cdi_lite} chapter and this section of specification defines them in depth.

[[scopes_full]]

=== Scopes in {cdi_full}
== Scopes in {cdi_full}

[[builtin_scopes_full]]

==== Built-in scope types in {cdi_full}
=== Built-in scope types in {cdi_full}

{cdi_full} adds a new standard scope to those defined in <<builtin_scopes>>

* The `@ConversationScoped` annotation represents the conversation scope defined in <<conversation_context>>.

[[bean_defining_annotations_full]]

==== Bean defining annotations in {cdi_full}
=== Bean defining annotations in {cdi_full}

{cdi_full} adds the following annotations to the set of bean defining annotations :

* `@ConversationScoped` annotation,
* `@Decorator` annotation.

[[names_full]]

=== Bean names in {cdi_full}

[[beans_with_no_name_full]]

==== Beans with no name in {cdi_full}

In addition to rules defined in <<beans_with_no_name>>, when running in {cdi_full} bean names have also the following restriction:

If a decorator has a name, non-portable behavior results.

[[alternatives_full]]

=== Alternatives in {cdi_full}

[[declaring_alternative_full]]

==== Declaring an alternative in {cdi_full}

In addition to rules defined in <<declaring_alternative>>, when running in {cdi_full} alternative have also the following restriction:

If a decorator is an alternative, non-portable behavior results.

[[stereotypes_full]]

=== Stereotypes in {cdi_full}

[[builtin_stereotypes_full]]

==== Built-in stereotypes in {cdi_full}

In addition to built-in stereotypes defined in <<builtin_stereotypes>>, {cdi_full} provides the special-purpose `@Decorator` stereotype, defined in <<decorator_annotation>>.
8 changes: 8 additions & 0 deletions spec/src/main/asciidoc/core/implementation.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ A Java class is a managed bean if it meets all of the following conditions:
** the class has a constructor with no parameters, or
** the class declares a constructor annotated `@Inject`.

In {cdi_full}, a Java class is a managed bean if:

* It is a non-abstract class, or is annotated `@Decorator`.

All Java classes that meet these conditions are managed beans and thus no special declaration is required to define a managed bean.

If packages annotated `@Vetoed` are split across classpath entries, non-portable behavior results.
Expand Down Expand Up @@ -715,6 +719,10 @@ A bean type must be proxyable if an injection point resolves to a bean:
* that requires a client proxy, or
* that has a bound interceptor.

In {cdi_full}, a bean be proxyable if an injection point resolves to a bean:

* that has an associated decorator.


Otherwise, the container automatically detects the problem, and treats it as a deployment problem.

68 changes: 0 additions & 68 deletions spec/src/main/asciidoc/core/implementation_full.adoc

This file was deleted.

2 changes: 1 addition & 1 deletion spec/src/main/asciidoc/core/scopescontexts.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ The `@Dependent` scope is always active.

Many instances of beans with scope `@Dependent` belong to some other bean and are called _dependent objects_.

* Instances interceptors are dependent objects of the bean instance they decorate.
* Instances of interceptors are dependent objects of the bean instance they decorate.
* An instance of a bean with scope `@Dependent` injected into a field, bean constructor or initializer method is a dependent object of the bean into which it was injected.
* An instance of a bean with scope `@Dependent` injected into a producer method is a dependent object of the producer method bean instance that is being produced.
* An instance of a bean with scope `@Dependent` obtained by direct invocation of an `Instance` is a dependent object of the instance of `Instance`.
Expand Down

0 comments on commit 8f869d2

Please sign in to comment.