-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve extension API and resolve all remaining open questions
- settled on the name "Build Compatible Extensions" - renamed `@Processing` to `@Registration`, because if we ever want to introduce an extension phase for modifying beans before they are registered, _that_ should be called `@Processing` - moved the synthetic bean creation/destruction functions from the `CreationalContext` style to the `Instance` style - specified precisely how `ClassInfo.methods` and `fields` work, specified that `ClassConfig` behaves identically, and specified that an extension methods with parameters of type `MethodInfo` or `FieldInfo` also behave identically - removed the `@ExactType` and `@SubtypesOf` annotations and moved type queries directly to the `@Enhancement` and `@Registration` annotations - moved the `MetaAnnotations` API from accepting a callback to directly returning `ClassConfig` - specified lifecycle of `SyntheticBean{Creator,Disposer}` and `SyntheticObserver` - specified that `Messages.error` is treated as a deployment problem
- Loading branch information
Showing
24 changed files
with
355 additions
and
369 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 67 additions & 11 deletions
78
api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/Enhancement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,92 @@ | ||
package jakarta.enterprise.inject.build.compatible.spi; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* 2nd phase of CDI Lite extension execution. | ||
* 2nd phase of {@linkplain BuildCompatibleExtension build compatible extension} execution. | ||
* Allows transforming annotations. | ||
* <p> | ||
* Methods annotated {@code @Enhancement} must define exactly one parameter of one of these types: | ||
* In the following text, the term <em>expected types</em> denotes the set of types defined by | ||
* the {@link #types() types}, {@link #withSubtypes() withSubtypes} and {@link #withAnnotations() withAnnotations} | ||
* members of the {@code @Enhancement} annotation. The term <em>discovered types</em> denotes | ||
* the subset of <em>expected types</em> that were discovered during bean discovery. | ||
* <p> | ||
* Methods annotated {@code @Enhancement} must declare exactly one parameter of one of these types: | ||
* <ul> | ||
* <li>{@link ClassConfig} or {@link jakarta.enterprise.lang.model.declarations.ClassInfo ClassInfo}</li> | ||
* <li>{@link MethodConfig} or {@link jakarta.enterprise.lang.model.declarations.MethodInfo MethodInfo}</li> | ||
* <li>{@link FieldConfig} or {@link jakarta.enterprise.lang.model.declarations.FieldInfo FieldInfo}</li> | ||
* <li>({@code ParameterConfig} or {@code ParameterInfo} is not possible, parameters must be accessed | ||
* through {@code MethodConfig} or {@code MethodInfo})</li> | ||
* </ul> | ||
* The method must also have at least one annotation {@link ExactType @ExactType} or {@link SubtypesOf @SubtypesOf}. | ||
* If an {@code @Enhancement} method has a parameter of type {@code ClassConfig} or {@code ClassInfo}, | ||
* the method is called once for each <em>discovered type</em>. | ||
* <p> | ||
* If an {@code @Enhancement} method has a parameter of type {@code MethodConfig} or {@code MethodInfo}, | ||
* the method is called once for each constructor or method that is declared on each <em>discovered type</em>, | ||
* as defined in {@link jakarta.enterprise.lang.model.declarations.ClassInfo#constructors() ClassInfo.constructors} | ||
* and {@link jakarta.enterprise.lang.model.declarations.ClassInfo#methods() ClassInfo.methods}. | ||
* <p> | ||
* You can also declare a parameter of type {@link Messages Messages} to produce log messages and validation errors. | ||
* If an {@code @Enhancement} method has a parameter of type {@code FieldConfig} or {@code FieldInfo}, | ||
* the method is called once for each field that is declared on each <em>discovered type</em>, as defined | ||
* in {@link jakarta.enterprise.lang.model.declarations.ClassInfo#fields() ClassInfo.fields}. | ||
* <p> | ||
* If you need to create instances of {@link jakarta.enterprise.lang.model.types.Type Type}, you can also declare | ||
* a parameter of type {@link Types}. It provides factory methods for the void pseudo-type, primitive types, | ||
* class types, array types, parameterized types and wildcard types. | ||
* Additionally, methods annotated {@code @Enhancement} may declare parameters of these types: | ||
* <ul> | ||
* <li>{@link Messages}</li> | ||
* <li>{@link Types}</li> | ||
* </ul> | ||
* <p> | ||
* If you need to create instances of {@link jakarta.enterprise.lang.model.AnnotationInfo AnnotationInfo}, | ||
* use {@link AnnotationBuilder}. | ||
* Finally, {@link AnnotationBuilder} may be used to create instances | ||
* of {@link jakarta.enterprise.lang.model.AnnotationInfo AnnotationInfo}. | ||
* | ||
* @since 4.0 | ||
*/ | ||
@Target(ElementType.METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface Enhancement { | ||
/** | ||
* Defines the set of <em>expected types</em>. If {@link #withSubtypes() withSubtypes} | ||
* is {@code true}, the set of <em>expected types</em> includes all direct and indirect | ||
* subtypes of these types. If {@link #withAnnotations() withAnnotations} is defined, | ||
* the set of <em>expected types</em> only includes types that use given annotations. | ||
* | ||
* @return the set of <em>expected types</em> | ||
*/ | ||
Class<?>[] types(); | ||
|
||
/** | ||
* If {@code true}, the set of <em>expected types</em> includes all direct and | ||
* indirect subtypes of given {@link #types() types}. | ||
* | ||
* @return whether subtypes should be included in the set of <em>expected types</em> | ||
*/ | ||
boolean withSubtypes() default false; | ||
|
||
/** | ||
* Narrows down the set of <em>expected types</em>, defined by {@link #types() types} | ||
* and {@link #withSubtypes() withSubtypes}, to types that use any of given annotations. | ||
* The annotation can appear on the type, or on any member of the type, or on any | ||
* parameter of any member of the type, or as a meta-annotation on any annotation | ||
* that is considered by these rules. | ||
* <p> | ||
* Defaults to the {@linkplain BeanDefiningAnnotations set of bean defining annotations}. | ||
* <p> | ||
* If empty, or if {@code java.lang.Annotation} is present, all annotations are used. | ||
* That is, the set of <em>expected types</em> is narrowed down to the set of types | ||
* that use any annotation. | ||
* | ||
* @return types of annotations that must be present on the <em>expected types</em> | ||
*/ | ||
Class<? extends Annotation>[] withAnnotations() default BeanDefiningAnnotations.class; | ||
|
||
/** | ||
* Marker annotation type that represents set of bean defining annotations after | ||
* the {@link Discovery @Discovery} phase is finished. That is, it includes custom | ||
* normal scope annotations as well as custom stereotypes. | ||
*/ | ||
@interface BeanDefiningAnnotations { | ||
} | ||
} |
46 changes: 0 additions & 46 deletions
46
api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/ExactType.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.