Skip to content

Commit

Permalink
API changes for allowing @priority on stereotypes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladicek committed Sep 14, 2021
1 parent 28b8c09 commit be70679
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
18 changes: 17 additions & 1 deletion api/src/main/java/jakarta/enterprise/inject/Stereotype.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
*
* <ul>
* <li>all beans with the stereotype have defaulted bean EL names, or that</li>
* <li>all beans with the stereotype are alternatives.</li>
* <li>all beans with the stereotype are alternatives, or that</li>
* <li>all beans with the stereotype have predefined {@code @Priority}.</li>
* </ul>
*
* <p>
Expand Down Expand Up @@ -120,6 +121,21 @@
* </pre>
*
* <p>
* A stereotype may declare a {@link jakarta.annotation.Priority &#064;Priority} annotation, which specifies that
* every bean with the stereotype has given priority. This enables and orders alternatives, interceptors, and decorators.
* </p>
*
* <pre>
* &#064;Alternative
* &#064;Priority(1)
* &#064;Stereotype
* &#064;Target(TYPE)
* &#064;Retention(RUNTIME)
* public @interface Mock {
* }
* </pre>
*
* <p>
* A stereotype may declare other stereotypes. Stereotype declarations are transitive. A stereotype declared by a second
* stereotype is inherited by all beans and other stereotypes that declare the second stereotype.
* </p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,29 @@ public interface StereotypeInfo {
* Returns whether this stereotype is meta-annotated {@link jakarta.enterprise.inject.Alternative @Alternative}.
* This means that all beans with this stereotype are alternatives.
*
* @return whether this stereotype is meta-annotated {@link jakarta.enterprise.inject.Alternative @Alternative}.
* @return whether this stereotype is meta-annotated {@link jakarta.enterprise.inject.Alternative @Alternative}
*/
boolean isAlternative();

// TODO https://github.com/eclipse-ee4j/cdi/issues/495
//int priority();
/**
* Returns whether this stereotype is meta-annotated {@link jakarta.annotation.Priority @Priority}.
* This means that all alternatives and interceptors with this stereotype will be enabled for the application
* and ordered using the {@linkplain #priority() priority value} (unless they declare priority explicitly).
*
* @return whether this stereotype is meta-annotated {@link jakarta.annotation.Priority @Priority}.
*/
boolean hasPriority();

/**
* Returns the priority value this stereotype declares using the {@link jakarta.annotation.Priority @Priority}
* meta-annotation. All alternatives and interceptors with this stereotype will be enabled for the application
* and ordered using this priority value (unless they declare priority explicitly).
* <p>
* Returns {@code 0} if this stereotype is not meta-annotated {@code @Priority}.
*
* @return the {@link jakarta.annotation.Priority @Priority} value declared by this stereotype
*/
int priority();

/**
* Returns whether this stereotype is meta-annotated {@link jakarta.inject.Named @Named}.
Expand Down

0 comments on commit be70679

Please sign in to comment.