Skip to content

Commit

Permalink
Allow using @priority within stereotypes.
Browse files Browse the repository at this point in the history
  • Loading branch information
manovotn committed Sep 13, 2021
1 parent 7b81e32 commit 330d499
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions spec/src/main/asciidoc/core/definition.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -731,13 +731,12 @@ A stereotype encapsulates any combination of:
A stereotype may also specify that:

* all beans with the stereotype have defaulted bean names, or that
* all beans with the stereotype are alternatives.
* all beans with the stereotype are alternatives, or that
* all beans with the stereotype have predefined `@Priority`.


A bean may declare zero, one or multiple stereotypes.

// TODO how about we finally allowed declaring `@Priority` on stereotypes?

[[defining_new_stereotype]]

==== Defining new stereotypes
Expand Down Expand Up @@ -839,6 +838,28 @@ We may specify that all mock objects are alternatives:
public @interface Mock {}
----

[[priority_stereotype]]

===== Declaring stereotype with `@Priority`

A stereotype may declare a `@Priority` annotation which functions as a means of enabling and ordering affected alternatives, interceptors and decorators.

If there are two different stereotypes declared by the bean that declare different priority values, then there is no default priority and the bean must explicitly declare a `@Priority` annotation. If it does not explicitly declare priority, the container automatically detects the problem and treats it as a definition error.

If a bean explicitly declares priority, any priority values declared by stereotypes are ignored.

Following sample shows a stereotype that can be used to mark bean as globally enabled alternative:

[source, java]
----
@Alternative
@Priority(Interceptor.Priority.APPLICATION + 5)
@Stereotype
@Target(TYPE)
@Retention(RUNTIME)
public @interface TestReplacementStereotype {}
----

[[stereotypes_with_additional_stereotypes]]

===== Stereotypes with additional stereotypes
Expand Down

0 comments on commit 330d499

Please sign in to comment.