diff --git a/api/pom.xml b/api/pom.xml index 6c9e1a70..82f75c2d 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -129,6 +129,7 @@ + 2.1.0-B1 2.0.0 4.0.0 2.0.0 @@ -154,6 +155,12 @@ 6.8.8 + + jakarta.annotation + jakarta.annotation-api + ${annotation.api.version} + + jakarta.inject jakarta.inject-api @@ -182,6 +189,11 @@ + + jakarta.annotation + jakarta.annotation-api + + jakarta.el jakarta.el-api @@ -190,6 +202,12 @@ jakarta.interceptor jakarta.interceptor-api + + + jakarta.annotation + jakarta.annotation-api + + diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/AnnotationBuilder.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/AnnotationBuilder.java index 096a1893..099a9a84 100644 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/AnnotationBuilder.java +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/AnnotationBuilder.java @@ -16,6 +16,9 @@ *
  • call {@link #build()} to create an {@link AnnotationInfo}.
  • * * One builder instance should not be used to create multiple annotations. + *

    + * Note that values of all members of given annotation type must be defined + * before calling {@code build()}. If they are not, {@code build()} will throw an exception. * * @since 4.0 */ @@ -67,7 +70,7 @@ default AnnotationBuilder value(boolean value) { * @param values the boolean array, must not be {@code null} * @return this {@code AnnotationBuilder} */ - default AnnotationBuilder value(boolean... values) { + default AnnotationBuilder value(boolean[] values) { return member(AnnotationMember.VALUE, values); } @@ -87,7 +90,7 @@ default AnnotationBuilder value(byte value) { * @param values the byte array, must not be {@code null} * @return this {@code AnnotationBuilder} */ - default AnnotationBuilder value(byte... values) { + default AnnotationBuilder value(byte[] values) { return member(AnnotationMember.VALUE, values); } @@ -107,7 +110,7 @@ default AnnotationBuilder value(short value) { * @param values the short array, must not be {@code null} * @return this {@code AnnotationBuilder} */ - default AnnotationBuilder value(short... values) { + default AnnotationBuilder value(short[] values) { return member(AnnotationMember.VALUE, values); } @@ -127,7 +130,7 @@ default AnnotationBuilder value(int value) { * @param values the int array, must not be {@code null} * @return this {@code AnnotationBuilder} */ - default AnnotationBuilder value(int... values) { + default AnnotationBuilder value(int[] values) { return member(AnnotationMember.VALUE, values); } @@ -147,7 +150,7 @@ default AnnotationBuilder value(long value) { * @param values the long array, must not be {@code null} * @return this {@code AnnotationBuilder} */ - default AnnotationBuilder value(long... values) { + default AnnotationBuilder value(long[] values) { return member(AnnotationMember.VALUE, values); } @@ -167,7 +170,7 @@ default AnnotationBuilder value(float value) { * @param values the float array, must not be {@code null} * @return this {@code AnnotationBuilder} */ - default AnnotationBuilder value(float... values) { + default AnnotationBuilder value(float[] values) { return member(AnnotationMember.VALUE, values); } @@ -187,7 +190,7 @@ default AnnotationBuilder value(double value) { * @param values the double array, must not be {@code null} * @return this {@code AnnotationBuilder} */ - default AnnotationBuilder value(double... values) { + default AnnotationBuilder value(double[] values) { return member(AnnotationMember.VALUE, values); } @@ -207,7 +210,7 @@ default AnnotationBuilder value(char value) { * @param values the char array, must not be {@code null} * @return this {@code AnnotationBuilder} */ - default AnnotationBuilder value(char... values) { + default AnnotationBuilder value(char[] values) { return member(AnnotationMember.VALUE, values); } @@ -227,7 +230,7 @@ default AnnotationBuilder value(String value) { * @param values the String array, must not be {@code null} or contain {@code null} * @return this {@code AnnotationBuilder} */ - default AnnotationBuilder value(String... values) { + default AnnotationBuilder value(String[] values) { return member(AnnotationMember.VALUE, values); } @@ -247,7 +250,7 @@ default AnnotationBuilder value(Enum value) { * @param values the enum array, must not be {@code null} or contain {@code null} * @return this {@code AnnotationBuilder} */ - default AnnotationBuilder value(Enum... values) { + default AnnotationBuilder value(Enum[] values) { return member(AnnotationMember.VALUE, values); } @@ -269,7 +272,7 @@ default AnnotationBuilder value(Class> enumType, String enumVa * @param enumValues names of the enum constants, must not be {@code null} or contain {@code null} * @return this {@code AnnotationBuilder} */ - default AnnotationBuilder value(Class> enumType, String... enumValues) { + default AnnotationBuilder value(Class> enumType, String[] enumValues) { return member(AnnotationMember.VALUE, enumType, enumValues); } @@ -291,7 +294,7 @@ default AnnotationBuilder value(ClassInfo enumType, String enumValue) { * @param enumValues names of the enum constants, must not be {@code null} or contain {@code null} * @return this {@code AnnotationBuilder} */ - default AnnotationBuilder value(ClassInfo enumType, String... enumValues) { + default AnnotationBuilder value(ClassInfo enumType, String[] enumValues) { return member(AnnotationMember.VALUE, enumType, enumValues); } @@ -311,7 +314,7 @@ default AnnotationBuilder value(Class value) { * @param values the class array, must not be {@code null} or contain {@code null} * @return this {@code AnnotationBuilder} */ - default AnnotationBuilder value(Class... values) { + default AnnotationBuilder value(Class[] values) { return member(AnnotationMember.VALUE, values); } @@ -331,7 +334,7 @@ default AnnotationBuilder value(ClassInfo value) { * @param values the class array, must not be {@code null} or contain {@code null} * @return this {@code AnnotationBuilder} */ - default AnnotationBuilder value(ClassInfo... values) { + default AnnotationBuilder value(ClassInfo[] values) { return member(AnnotationMember.VALUE, values); } @@ -371,7 +374,7 @@ default AnnotationBuilder value(Type value) { * @return this {@code AnnotationBuilder} * @throws IllegalArgumentException if any given type is invalid, as described above */ - default AnnotationBuilder value(Type... values) { + default AnnotationBuilder value(Type[] values) { return member(AnnotationMember.VALUE, values); } @@ -391,7 +394,7 @@ default AnnotationBuilder value(AnnotationInfo value) { * @param values the annotation array, must not be {@code null} or contain {@code null} * @return this {@code AnnotationBuilder} */ - default AnnotationBuilder value(AnnotationInfo... values) { + default AnnotationBuilder value(AnnotationInfo[] values) { return member(AnnotationMember.VALUE, values); } @@ -411,7 +414,7 @@ default AnnotationBuilder value(Annotation value) { * @param values the annotation array, must not be {@code null} or contain {@code null} * @return this {@code AnnotationBuilder} */ - default AnnotationBuilder value(Annotation... values) { + default AnnotationBuilder value(Annotation[] values) { return member(AnnotationMember.VALUE, values); } @@ -440,7 +443,7 @@ default AnnotationBuilder value(Annotation... values) { * @param values the boolean array, must not be {@code null} * @return this {@code AnnotationBuilder} */ - AnnotationBuilder member(String name, boolean... values); + AnnotationBuilder member(String name, boolean[] values); /** * Adds a byte-valued annotation member with given {@code name}. @@ -458,7 +461,7 @@ default AnnotationBuilder value(Annotation... values) { * @param values the byte array, must not be {@code null} * @return this {@code AnnotationBuilder} */ - AnnotationBuilder member(String name, byte... values); + AnnotationBuilder member(String name, byte[] values); /** * Adds a short-valued annotation member with given {@code name}. @@ -476,7 +479,7 @@ default AnnotationBuilder value(Annotation... values) { * @param values the short array, must not be {@code null} * @return this {@code AnnotationBuilder} */ - AnnotationBuilder member(String name, short... values); + AnnotationBuilder member(String name, short[] values); /** * Adds an int-valued annotation member with given {@code name}. @@ -494,7 +497,7 @@ default AnnotationBuilder value(Annotation... values) { * @param values the int array, must not be {@code null} * @return this {@code AnnotationBuilder} */ - AnnotationBuilder member(String name, int... values); + AnnotationBuilder member(String name, int[] values); /** * Adds a long-valued annotation member with given {@code name}. @@ -512,7 +515,7 @@ default AnnotationBuilder value(Annotation... values) { * @param values the long array, must not be {@code null} * @return this {@code AnnotationBuilder} */ - AnnotationBuilder member(String name, long... values); + AnnotationBuilder member(String name, long[] values); /** * Adds a float-valued annotation member with given {@code name}. @@ -530,7 +533,7 @@ default AnnotationBuilder value(Annotation... values) { * @param values the float array, must not be {@code null} * @return this {@code AnnotationBuilder} */ - AnnotationBuilder member(String name, float... values); + AnnotationBuilder member(String name, float[] values); /** * Adds a double-valued annotation member with given {@code name}. @@ -548,7 +551,7 @@ default AnnotationBuilder value(Annotation... values) { * @param values the double array, must not be {@code null} * @return this {@code AnnotationBuilder} */ - AnnotationBuilder member(String name, double... values); + AnnotationBuilder member(String name, double[] values); /** * Adds a char-valued annotation member with given {@code name}. @@ -566,7 +569,7 @@ default AnnotationBuilder value(Annotation... values) { * @param values the char array, must not be {@code null} * @return this {@code AnnotationBuilder} */ - AnnotationBuilder member(String name, char... values); + AnnotationBuilder member(String name, char[] values); /** * Adds a String-valued annotation member with given {@code name}. @@ -584,7 +587,7 @@ default AnnotationBuilder value(Annotation... values) { * @param values the String array, must not be {@code null} or contain {@code null} * @return this {@code AnnotationBuilder} */ - AnnotationBuilder member(String name, String... values); + AnnotationBuilder member(String name, String[] values); /** * Adds an enum-valued annotation member with given {@code name}. @@ -602,7 +605,7 @@ default AnnotationBuilder value(Annotation... values) { * @param values the enum array, must not be {@code null} or contain {@code null} * @return this {@code AnnotationBuilder} */ - AnnotationBuilder member(String name, Enum... values); + AnnotationBuilder member(String name, Enum[] values); /** * Adds an enum-valued annotation member with given {@code name}. @@ -622,7 +625,7 @@ default AnnotationBuilder value(Annotation... values) { * @param enumValues names of the enum constants, must not be {@code null} or contain {@code null} * @return this {@code AnnotationBuilder} */ - AnnotationBuilder member(String name, Class> enumType, String... enumValues); + AnnotationBuilder member(String name, Class> enumType, String[] enumValues); /** * Adds an enum-valued annotation member with given {@code name}. @@ -642,7 +645,7 @@ default AnnotationBuilder value(Annotation... values) { * @param enumValues names of the enum constants, must not be {@code null} or contain {@code null} * @return this {@code AnnotationBuilder} */ - AnnotationBuilder member(String name, ClassInfo enumType, String... enumValues); + AnnotationBuilder member(String name, ClassInfo enumType, String[] enumValues); /** * Adds a class-valued annotation member with given {@code name}. @@ -660,7 +663,7 @@ default AnnotationBuilder value(Annotation... values) { * @param values the class array, must not be {@code null} or contain {@code null} * @return this {@code AnnotationBuilder} */ - AnnotationBuilder member(String name, Class... values); + AnnotationBuilder member(String name, Class[] values); /** * Adds a class-valued annotation member with given {@code name}. @@ -678,7 +681,7 @@ default AnnotationBuilder value(Annotation... values) { * @param values the class array, must not be {@code null} or contain {@code null} * @return this {@code AnnotationBuilder} */ - AnnotationBuilder member(String name, ClassInfo... values); + AnnotationBuilder member(String name, ClassInfo[] values); /** * Adds a class-valued annotation member with given {@code name}. @@ -717,7 +720,7 @@ default AnnotationBuilder value(Annotation... values) { * @return this {@code AnnotationBuilder} * @throws IllegalArgumentException if any given type is invalid, as described above */ - AnnotationBuilder member(String name, Type... values); + AnnotationBuilder member(String name, Type[] values); /** * Adds an annotation-valued annotation member with given {@code name}. @@ -735,7 +738,7 @@ default AnnotationBuilder value(Annotation... values) { * @param values the annotation array, must not be {@code null} or contain {@code null} * @return this {@code AnnotationBuilder} */ - AnnotationBuilder member(String name, AnnotationInfo... values); + AnnotationBuilder member(String name, AnnotationInfo[] values); /** * Adds an annotation-valued annotation member with given {@code name}. @@ -753,13 +756,14 @@ default AnnotationBuilder value(Annotation... values) { * @param values the annotation array, must not be {@code null} or contain {@code null} * @return this {@code AnnotationBuilder} */ - AnnotationBuilder member(String name, Annotation... values); + AnnotationBuilder member(String name, Annotation[] values); /** * Returns an {@link AnnotationInfo} that includes all annotation members defined by previous method calls * on this builder. After {@code build()} is called, this builder instance should be discarded. * * @return the built {@link AnnotationInfo}, never {@code null} + * @throws IllegalStateException if a value of some annotation member wasn't set */ AnnotationInfo build(); } diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/BeanInfo.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/BeanInfo.java index 39dc4581..957bd1cd 100644 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/BeanInfo.java +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/BeanInfo.java @@ -82,7 +82,7 @@ public interface BeanInfo { /** * Returns whether this bean is synthetic. In other words, whether this bean - * doesn't correspond to a declaration in program source code and was created + * does not correspond to a declaration in program source code and was created * through other means (e.g. using an extension). * * @return whether this bean is synthetic @@ -91,17 +91,17 @@ public interface BeanInfo { /** * Returns the producer {@linkplain MethodInfo method} that defines this bean. - * Returns {@code null} if this bean isn't defined by a producer method. + * Returns {@code null} if this bean is not defined by a producer method. * - * @return producer method that defines this bean, or {@code null} if this bean isn't defined by a producer method + * @return producer method that defines this bean, or {@code null} if this bean is not defined by a producer method */ MethodInfo producerMethod(); /** * Returns the producer {@linkplain FieldInfo field} that defines this bean. - * Returns {@code null} if this bean isn't defined by a producer field. + * Returns {@code null} if this bean is not defined by a producer field. * - * @return producer field that defines this bean, or {@code null} if this bean isn't defined by a producer field + * @return producer field that defines this bean, or {@code null} if this bean is not defined by a producer field */ FieldInfo producerField(); @@ -124,18 +124,18 @@ public interface BeanInfo { /** * Returns the bean name of this bean. A bean name is usually defined * using the {@link jakarta.inject.Named @Named} annotation. - * Returns {@code null} if the bean doesn't have a name. + * Returns {@code null} if the bean does not have a name. * - * @return the bean name, or {@code null} if the bean doesn't have a name + * @return the bean name, or {@code null} if the bean does not have a name */ String getName(); /** * Returns the {@linkplain DisposerInfo disposer} method of this producer-based bean. * Returns {@code null} if this bean is not a defined by a producer method or a producer field, - * or if this producer-based bean doesn't have a corresponding disposer method. + * or if this producer-based bean does not have a corresponding disposer method. * - * @return the {@linkplain DisposerInfo disposer}, or {@code null} if this bean doesn't have a disposer + * @return the {@linkplain DisposerInfo disposer}, or {@code null} if this bean does not have a disposer */ DisposerInfo disposer(); @@ -146,12 +146,31 @@ public interface BeanInfo { */ Collection stereotypes(); - // TODO interceptors? - /** * Returns a collection of this bean's {@linkplain InjectionPointInfo injection points}. * * @return immutable collection of injection points, never {@code null} */ Collection injectionPoints(); + + // --- + + /** + * Returns whether this bean is an interceptor. + * + * @return whether this bean is an interceptor + */ + default boolean isInterceptor() { + return false; + } + + /** + * Returns this bean as an {@linkplain InterceptorInfo interceptor}. + * + * @return this interceptor, never {@code null} + * @throws IllegalStateException if {@link #isInterceptor()} returns {@code false} + */ + default InterceptorInfo asInterceptor() { + throw new IllegalStateException("Not an interceptor"); + } } diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/BuildCompatibleExtension.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/BuildCompatibleExtension.java index 68ea35f3..fa2667fb 100644 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/BuildCompatibleExtension.java +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/BuildCompatibleExtension.java @@ -22,13 +22,20 @@ * on the particular processing phase and is documented in the corresponding extension annotation. * All the parameters will be provided by the container when the extension is invoked. *

    - * Extension methods can be assigned a priority using {@link ExtensionPriority @ExtensionPriority}. - * Note that priority only affects order of extensions in a single phase. + * Extension methods can be assigned a priority using {@link jakarta.annotation.Priority @Priority}. + * Extension methods with smaller priority values are invoked first. Extension methods without specified priority + * have a default priority of {@link jakarta.interceptor.Interceptor.Priority#APPLICATION Priority.APPLICATION} + 500. + * If two extension methods have equal priority, the ordering among them is undefined. Note that priority + * only affects order of extensions in a single phase. *

    * If the extension declares multiple methods, they are all invoked on the same instance of the class. *

    * Extension classes can be annotated {@link SkipIfPortableExtensionPresent @SkipIfPortablExtensionPresent} * when they are supposed to be ignored in presence of a given portable extension. + *

    + * CDI implementations are not required to accept custom implementations of any {@code jakarta.enterprise.lang.model} + * or {@code jakarta.enterprise.inject.build.compatible.spi} interface. In other words, users may only use instances + * of these interfaces that they previously obtained from the corresponding API. If not, non-portable behavior results. * * @since 4.0 */ diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/ClassConfig.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/ClassConfig.java index 82280ff4..5a6bff5b 100644 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/ClassConfig.java +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/ClassConfig.java @@ -29,7 +29,7 @@ public interface ClassConfig extends DeclarationConfig { /** * Adds a marker annotation of given type to this class. - * Doesn't allow configuring annotation members. + * Does not allow configuring annotation members. * * @param annotationType the annotation type, must not be {@code null} * @return this configurator object, to allow fluent usage diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/DeclarationConfig.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/DeclarationConfig.java index 2bfa10db..16796d4f 100644 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/DeclarationConfig.java +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/DeclarationConfig.java @@ -24,7 +24,7 @@ public interface DeclarationConfig { /** * Adds a marker annotation of given type to this declaration. - * Doesn't allow configuring annotation members. + * Does not allow configuring annotation members. * * @param annotationType the annotation type, must not be {@code null} * @return this configurator object, to allow fluent usage diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/Enhancement.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/Enhancement.java index 3aa57b60..78569306 100644 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/Enhancement.java +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/Enhancement.java @@ -11,7 +11,6 @@ *

    * Methods annotated {@code @Enhancement} must define exactly one parameter of one of these types: *

      - *
    • {@link DeclarationConfig} or {@link jakarta.enterprise.lang.model.declarations.DeclarationInfo DeclarationInfo}
    • *
    • {@link ClassConfig} or {@link jakarta.enterprise.lang.model.declarations.ClassInfo ClassInfo}
    • *
    • {@link MethodConfig} or {@link jakarta.enterprise.lang.model.declarations.MethodInfo MethodInfo}
    • *
    • {@link FieldConfig} or {@link jakarta.enterprise.lang.model.declarations.FieldInfo FieldInfo}
    • diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/ExactType.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/ExactType.java index 6f0e6b6c..7107aa18 100644 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/ExactType.java +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/ExactType.java @@ -18,6 +18,8 @@ *

      * If the {@code @Processing} method has a parameter of type {@code BeanInfo}, * the method is called once for each bean whose set of bean types contains at least one given type. + * If the {@code @Processing} method has a parameter of type {@code InterceptorInfo}, + * the method is called once for each interceptor whose set of bean types contains at least one given type. * If the {@code @Processing} method has a parameter of type {@code ObserverInfo}, * the method is called once for each observer whose observed event type is present in the set of given types. *

      diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/ExtensionPriority.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/ExtensionPriority.java deleted file mode 100644 index 93bf41a5..00000000 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/ExtensionPriority.java +++ /dev/null @@ -1,26 +0,0 @@ -package jakarta.enterprise.inject.build.compatible.spi; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Allows specifying priority of extension methods. - *

      - * Extension methods with smaller priority values are invoked first. - * Extension methods without specified priority are treated as methods with priority {@code 10_000}; - * If two extension methods have equal priority, the ordering among them is undefined. - * - * @see BuildCompatibleExtension - */ -// TODO this should be removed and @Priority should be used instead; -// see https://github.com/eclipse-ee4j/common-annotations-api/pull/87 -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -public @interface ExtensionPriority { - /** - * @return the priority value - */ - int value(); -} diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/FieldConfig.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/FieldConfig.java index b0cfe28b..86d7eb52 100644 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/FieldConfig.java +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/FieldConfig.java @@ -25,7 +25,7 @@ public interface FieldConfig extends DeclarationConfig { /** * Adds a marker annotation of given type to this field. - * Doesn't allow configuring annotation members. + * Does not allow configuring annotation members. * * @param annotationType the annotation type, must not be {@code null} * @return this configurator object, to allow fluent usage diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/InterceptorInfo.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/InterceptorInfo.java new file mode 100644 index 00000000..1e5e3608 --- /dev/null +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/InterceptorInfo.java @@ -0,0 +1,50 @@ +package jakarta.enterprise.inject.build.compatible.spi; + +import jakarta.enterprise.inject.spi.InterceptionType; +import jakarta.enterprise.lang.model.AnnotationInfo; + +import java.util.Collection; + +/** + * Interceptors are managed beans annotated {@link jakarta.interceptor.Interceptor @Interceptor}. + * An interceptor declares a set of {@linkplain jakarta.interceptor.InterceptorBinding interceptor binding annotations}, + * used to associate the interceptor with target beans. It also declares at least one interceptor method: + *

        + *
      • for business method invocations: {@link jakarta.interceptor.AroundInvoke @AroundInvoke},
      • + *
      • for constructor invocations: {@link jakarta.interceptor.AroundConstruct @AroundConstruct},
      • + *
      • for lifecycle callbacks: {@link jakarta.annotation.PostConstruct @PostConstruct}, + * {@link jakarta.annotation.PreDestroy @PreDestroy}.
      • + *
      + * Finally, an interceptor that is enabled also declares {@link jakarta.annotation.Priority @Priority}. + * + * @since 4.0 + */ +public interface InterceptorInfo extends BeanInfo { + /** + * Returns the set of {@linkplain jakarta.interceptor.InterceptorBinding interceptor binding annotations} + * declared on this interceptor. + * + * @return immutable set of interceptor binding annotations, never {@code null} + */ + Collection interceptorBindings(); + + /** + * Returns whether this interceptor intercepts given {@linkplain InterceptionType kind of methods}. + * + * @param interceptionType the kind of interception + * @return whether this interceptor intercepts given kind of methods + */ + boolean intercepts(InterceptionType interceptionType); + + // --- + + @Override + default boolean isInterceptor() { + return true; + } + + @Override + default InterceptorInfo asInterceptor() { + return this; + } +} diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/MetaAnnotations.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/MetaAnnotations.java index bf995924..0e5b8ff3 100644 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/MetaAnnotations.java +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/MetaAnnotations.java @@ -18,7 +18,7 @@ public interface MetaAnnotations { /** * Registers {@code annotation} as a qualifier annotation. Only makes sense if the annotation - * isn't meta-annotated {@code @Qualifier}. + * is not meta-annotated {@code @Qualifier}. * * @param annotation annotation type * @param config allows transforming annotations on the {@code annotation} @@ -27,7 +27,7 @@ public interface MetaAnnotations { /** * Registers {@code annotation} as an interceptor binding annotation. Only makes sense if the annotation - * isn't meta-annotated {@code @InterceptorBinding}. + * is not meta-annotated {@code @InterceptorBinding}. * * @param annotation annotation type * @param config allows transforming annotations on the {@code annotation} @@ -36,7 +36,7 @@ public interface MetaAnnotations { /** * Registers {@code annotation} as a stereotype annotation. Only makes sense if the annotation - * isn't meta-annotated {@code @Stereotype}. + * is not meta-annotated {@code @Stereotype}. * * @param annotation annotation type * @param config allows transforming annotations on the {@code annotation} @@ -53,7 +53,7 @@ public interface MetaAnnotations { * * @param scopeAnnotation the scope annotation type, must not be {@code null} * @param contextClass the context class, must not be {@code null} - * @throws IllegalArgumentException if the {@code scopeAnnotation} isn't meta-annotated {@code @NormalScope} + * @throws IllegalArgumentException if the {@code scopeAnnotation} is not meta-annotated {@code @NormalScope} * or {@code @Scope} */ void addContext(Class scopeAnnotation, Class contextClass); diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/MethodConfig.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/MethodConfig.java index 47123263..2a0d2417 100644 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/MethodConfig.java +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/MethodConfig.java @@ -25,7 +25,7 @@ public interface MethodConfig extends DeclarationConfig { /** * Adds a marker annotation of given type to this method. - * Doesn't allow configuring annotation members. + * Does not allow configuring annotation members. * * @param annotationType the annotation type, must not be {@code null} * @return this configurator object, to allow fluent usage diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/Parameters.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/Parameters.java new file mode 100644 index 00000000..148506d3 --- /dev/null +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/Parameters.java @@ -0,0 +1,88 @@ +package jakarta.enterprise.inject.build.compatible.spi; + +/** + * A {@code String}-keyed parameter map. The parameter mappings are defined + * by a synthetic component builder. The CDI container passes the map + * to functions defined by the same synthetic component builder, whenever + * it needs to invoke those functions. That is: + * + *
        + *
      • a synthetic bean {@linkplain SyntheticBeanCreator creation} and + * {@linkplain SyntheticBeanDisposer destruction} function, defined by + * {@link SyntheticBeanBuilder};
      • + *
      • a synthetic observer {@linkplain SyntheticObserver notification} + * function, defined by {@link SyntheticObserverBuilder}.
      • + *
      + * + * Parameter values are transferred from the builder to the {@code Parameters}-accepting + * function without a change. For example, if the builder defines an {@code int} parameter, + * it must be looked up as {@code int} and cannot be looked up as {@code long}. + *

      + * Values of primitive types may be looked up either using the primitive type (such as + * {@code int.class}), or using the corresponding wrapper type ({@code Integer.class}). + * The return value is always of the wrapper type. + *

      + * Class-typed parameters are available as instances of {@link Class}, even if an instance + * of {@code ClassInfo} was passed to the builder. + *

      + * Similarly, annotation-typed parameters are always available as instances of the annotation + * type, even if an instance of {@code AnnotationInfo} was passed to the builder. + */ +public interface Parameters { + /** + * Returns the parameter with given {@code key}. The value is expected to be of given type. + * + * @param key the parameter key; must not be {@code null} + * @param type the parameter type; must not be {@code null} + * @param the parameter type + * @return the parameter value, or {@code null} if parameter with given {@code key} does not exist + * @throws ClassCastException if the parameter exists, but is of a different type + */ + T get(String key, Class type); + + /** + * Returns the parameter with given {@code key}. The value is expected to be of given type. + * If the parameter does not exist, returns {@code defaultValue}. + * + * @param key the parameter key; must not be {@code null} + * @param type the parameter type; must not be {@code null} + * @param the parameter type + * @return the parameter value, or {@code defaultValue} if parameter with given {@code key} does not exist + * @throws ClassCastException if the parameter exists, but is of a different type + */ + T get(String key, Class type, T defaultValue); + + // TODO another possible design would be (with or without the methods accepting default values): + // - Boolean getBoolean(String key) + // - boolean getBoolean(String key, boolean defaultValue) + // - boolean[] getBooleans(String key) + // - boolean[] getBooleans(String key, boolean[] defaultValues) + // - Integer getInt(String key) + // - int getInt(String key, int defaultValue) + // - int[] getInts(String key) + // - int[] getInts(String key, int[] defaultValues) + // - Long getLong(String key) + // - long getLong(String key, long defaultValue) + // - long[] getLongs(String key) + // - long[] getLongs(String key, long[] defaultValues) + // - Double getDouble(String key) + // - double getDouble(String key, double defaultValue) + // - double[] getDoubles(String key) + // - double[] getDoubles(String key, double[] defaultValues) + // - String getString(String key) + // - String getString(String key, String defaultValue) + // - String[] getStrings(String key) + // - String[] getStrings(String key, String[] defaultValues) + // - Enum getEnum(String key) + // - Enum getEnum(String key, Enum defaultValue) + // - Enum[] getEnums(String key) + // - Enum[] getEnums(String key, Enum[] defaultValues) + // - Class getClass(String key) -- different name would be better, as java.lang.Object has getClass() + // - Class getClass(String key, Class defaultValue) + // - Class[] getClasses(String key) + // - Class[] getClasses(String key, Class[] defaultValues) + // - Annotation getAnnotation(String key) + // - Annotation getAnnotation(String key, Annotation defaultValue) + // - Annotation[] getAnnotations(String key) + // - Annotation[] getAnnotations(String key, Annotation[] defaultValues) +} diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/Processing.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/Processing.java index c3ac6ecb..1cf259ca 100644 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/Processing.java +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/Processing.java @@ -12,9 +12,13 @@ *

      * Methods annotated {@code @Processing} must define exactly one parameter of one of these types: *

        - *
      • {@link BeanInfo BeanInfo}
      • - *
      • {@link ObserverInfo ObserverInfo}
      • + *
      • {@link BeanInfo}
      • + *
      • {@link InterceptorInfo}
      • + *
      • {@link ObserverInfo}
      • *
      + * Note that interceptors are beans, and {@code InterceptorInfo} is a subtype of {@code BeanInfo}, so if the method + * has a parameter of type {@code BeanInfo}, it will be called for interceptors as well. + *

      * The method must also have at least one annotation {@link ExactType @ExactType} or {@link SubtypesOf @SubtypesOf}. *

      * You can also declare a parameter of type {@link Messages Messages} to produce log messages and validation errors. diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/StereotypeInfo.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/StereotypeInfo.java index 28e23be3..c37a0523 100644 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/StereotypeInfo.java +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/StereotypeInfo.java @@ -14,7 +14,7 @@ public interface StereotypeInfo { /** * Returns the {@linkplain ScopeInfo default scope} defined by this stereotype. - * Returns {@code null} if this stereotype doesn't define a default scope. + * Returns {@code null} if this stereotype does not define a default scope. * * @return the default scope or {@code null} */ @@ -22,7 +22,7 @@ public interface StereotypeInfo { /** * Returns the set of {@linkplain AnnotationInfo interceptor binding annotations} defined by this stereotype. - * Returns an empty collection if this stereotype doesn't define any interceptor binding. + * Returns an empty collection if this stereotype does not define any interceptor binding. * * @return immutable collection of {@linkplain AnnotationInfo interceptor binding annotations}, never {@code null} */ diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SubtypesOf.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SubtypesOf.java index ee5e72d5..71064408 100644 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SubtypesOf.java +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SubtypesOf.java @@ -19,6 +19,8 @@ *

      * If the {@code @Processing} method has a parameter of type {@code BeanInfo}, * the method is called once for each bean whose set of bean types contains at least one subtype of any given type. + * If the {@code @Processing} method has a parameter of type {@code InterceptorInfo}, + * the method is called once for each interceptor whose set of bean types contains at least one subtype of any given type. * If the {@code @Processing} method has a parameter of type {@code ObserverInfo}, * the method is called once for each observer whose observed event type is present in the set of subtypes of any give type. *

      diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticBeanBuilder.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticBeanBuilder.java index 6348df43..2f48f20e 100644 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticBeanBuilder.java +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticBeanBuilder.java @@ -273,6 +273,28 @@ public interface SyntheticBeanBuilder { */ SyntheticBeanBuilder withParam(String key, String[] value); + /** + * Adds an enum-valued parameter to the map of construction/destruction parameters. + * The parameter map is passed to the {@linkplain SyntheticBeanCreator creation} and + * {@linkplain SyntheticBeanDisposer destruction} function when the bean is instantiated/disposed. + * + * @param key the parameter key, must not be {@code null} + * @param value the parameter value + * @return this {@code SyntheticBeanBuilder} + */ + SyntheticBeanBuilder withParam(String key, Enum value); + + /** + * Adds an enum array-valued parameter to the map of construction/destruction parameters. + * The parameter map is passed to the {@linkplain SyntheticBeanCreator creation} and + * {@linkplain SyntheticBeanDisposer destruction} function when the bean is instantiated/disposed. + * + * @param key the parameter key, must not be {@code null} + * @param value the parameter value + * @return this {@code SyntheticBeanBuilder} + */ + SyntheticBeanBuilder withParam(String key, Enum[] value); + /** * Adds a {@code Class}-valued parameter to the map of construction/destruction parameters. * The parameter map is passed to the {@linkplain SyntheticBeanCreator creation} and @@ -283,7 +305,20 @@ public interface SyntheticBeanBuilder { * @return this {@code SyntheticBeanBuilder} */ SyntheticBeanBuilder withParam(String key, Class value); - // TODO add a variant that takes a `ClassInfo`? the value would be `Class` at runtime + + /** + * Adds a {@code Class}-valued parameter to the map of construction/destruction parameters. + * The parameter map is passed to the {@linkplain SyntheticBeanCreator creation} and + * {@linkplain SyntheticBeanDisposer destruction} function when the bean is instantiated/disposed. + *

      + * When looked up from the parameter map in the creation/destruction function, the value will be + * an instance of {@link Class}, not a {@code ClassInfo}. + * + * @param key the parameter key, must not be {@code null} + * @param value the parameter value + * @return this {@code SyntheticBeanBuilder} + */ + SyntheticBeanBuilder withParam(String key, ClassInfo value); /** * Adds a {@code Class} array-valued parameter to the map of construction/destruction parameters. @@ -295,10 +330,23 @@ public interface SyntheticBeanBuilder { * @return this {@code SyntheticBeanBuilder} */ SyntheticBeanBuilder withParam(String key, Class[] value); - // TODO add a variant that takes a `ClassInfo[]`? the value would be `Class[]` at runtime /** - * Adds an {@code annotation}-valued parameter to the map of construction/destruction parameters. + * Adds a {@code Class} array-valued parameter to the map of construction/destruction parameters. + * The parameter map is passed to the {@linkplain SyntheticBeanCreator creation} and + * {@linkplain SyntheticBeanDisposer destruction} function when the bean is instantiated/disposed. + *

      + * When looked up from the parameter map in the creation/destruction function, the values will be + * instances of {@link Class}, not {@code ClassInfo}. + * + * @param key the parameter key, must not be {@code null} + * @param value the parameter value + * @return this {@code SyntheticBeanBuilder} + */ + SyntheticBeanBuilder withParam(String key, ClassInfo[] value); + + /** + * Adds an annotation-valued parameter to the map of construction/destruction parameters. * The parameter map is passed to the {@linkplain SyntheticBeanCreator creation} and * {@linkplain SyntheticBeanDisposer destruction} function when the bean is instantiated/disposed. *

      @@ -312,7 +360,7 @@ public interface SyntheticBeanBuilder { SyntheticBeanBuilder withParam(String key, AnnotationInfo value); /** - * Adds an {@code annotation}-valued parameter to the map of construction/destruction parameters. + * Adds an annotation-valued parameter to the map of construction/destruction parameters. * The parameter map is passed to the {@linkplain SyntheticBeanCreator creation} and * {@linkplain SyntheticBeanDisposer destruction} function when the bean is instantiated/disposed. * @@ -323,7 +371,7 @@ public interface SyntheticBeanBuilder { SyntheticBeanBuilder withParam(String key, Annotation value); /** - * Adds an {@code annotation} array-valued parameter to the map of construction/destruction parameters. + * Adds an annotation array-valued parameter to the map of construction/destruction parameters. * The parameter map is passed to the {@linkplain SyntheticBeanCreator creation} and * {@linkplain SyntheticBeanDisposer destruction} function when the bean is instantiated/disposed. *

      @@ -337,7 +385,7 @@ public interface SyntheticBeanBuilder { SyntheticBeanBuilder withParam(String key, AnnotationInfo[] value); /** - * Adds an {@code annotation} array-valued parameter to the map of construction/destruction parameters. + * Adds an annotation array-valued parameter to the map of construction/destruction parameters. * The parameter map is passed to the {@linkplain SyntheticBeanCreator creation} and * {@linkplain SyntheticBeanDisposer destruction} function when the bean is instantiated/disposed. * diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticBeanCreator.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticBeanCreator.java index 051a86c1..f1eabeda 100644 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticBeanCreator.java +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticBeanCreator.java @@ -1,6 +1,5 @@ package jakarta.enterprise.inject.build.compatible.spi; -import java.util.Map; import jakarta.enterprise.context.spi.CreationalContext; import jakarta.enterprise.inject.spi.InjectionPoint; @@ -18,16 +17,14 @@ public interface SyntheticBeanCreator { /** * Creates an instance of the synthetic bean. *

      - * The parameter map is defined by the {@link SyntheticBeanBuilder}. Note that - * annotation-typed parameters are always passed to this function as instances of - * the annotation type, even if an instance of {@code AnnotationInfo} was passed - * to the {@code SyntheticBeanBuilder}. + * The parameter map contains the same values that were passed to + * the {@link SyntheticBeanBuilder} that defined the synthetic bean. * * @param creationalContext the creational context, never {@code null} * @param injectionPoint the injection point into which the new instance will be injected, * or {@code null} if the synthetic bean is not {@code @Dependent} - * @param params immutable map of parameters, never {@code null} + * @param params the parameter map, never {@code null} * @return an instance of the bean, may only be {@code null} if the synthetic bean is {@code @Dependent} */ - T create(CreationalContext creationalContext, InjectionPoint injectionPoint, Map params); + T create(CreationalContext creationalContext, InjectionPoint injectionPoint, Parameters params); } diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticBeanDisposer.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticBeanDisposer.java index eb7ebb48..96c87ca0 100644 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticBeanDisposer.java +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticBeanDisposer.java @@ -1,6 +1,5 @@ package jakarta.enterprise.inject.build.compatible.spi; -import java.util.Map; import jakarta.enterprise.context.spi.CreationalContext; /** @@ -17,14 +16,12 @@ public interface SyntheticBeanDisposer { /** * Destroys an instance of the synthetic bean. *

      - * The parameter map is defined by the {@link SyntheticBeanBuilder}. Note that - * annotation-typed parameters are always passed to this function as instances of - * the annotation type, even if an instance of {@code AnnotationInfo} was passed - * to the {@code SyntheticBeanBuilder}. + * The parameter map contains the same values that were passed to + * the {@link SyntheticBeanBuilder} that defined the synthetic bean. * * @param instance the synthetic bean instance, never {@code null} (TODO what if @Dependent?) * @param creationalContext the creational context, never {@code null} - * @param params immutable map of parameters, never {@code null} + * @param params the parameter map, never {@code null} */ - void dispose(T instance, CreationalContext creationalContext, Map params); + void dispose(T instance, CreationalContext creationalContext, Parameters params); } diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticObserver.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticObserver.java index 4cf6ee0f..ffa3b34b 100644 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticObserver.java +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticObserver.java @@ -3,8 +3,6 @@ import jakarta.enterprise.event.ObserverException; import jakarta.enterprise.inject.spi.EventContext; -import java.util.Map; - /** * The event notification function for a synthetic observer defined by {@link SyntheticObserverBuilder}. * Implementations must be {@code public} classes with a {@code public} zero-parameter constructor. @@ -17,14 +15,12 @@ public interface SyntheticObserver { * Consumes an event. The {@link EventContext} provides access to the event payload, * as well as the {@link jakarta.enterprise.inject.spi.EventMetadata EventMetadata}. *

      - * The parameter map is defined by the {@link SyntheticObserverBuilder}. Note that - * annotation-typed parameters are always passed to this function as instances of - * the annotation type, even if an instance of {@code AnnotationInfo} was passed - * to the {@code SyntheticObserverBuilder}. + * The parameter map contains the same values that were passed to + * the {@link SyntheticObserverBuilder} that defined the synthetic observer. * * @param event the event context, never {@code null} - * @param params immutable map of parameters, never {@code null} + * @param params the parameter map, never {@code null} * @throws Exception checked exception will be wrapped and rethrown as an {@link ObserverException} */ - void observe(EventContext event, Map params) throws Exception; + void observe(EventContext event, Parameters params) throws Exception; } diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticObserverBuilder.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticObserverBuilder.java index 70f16a6e..f4d71a25 100644 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticObserverBuilder.java +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticObserverBuilder.java @@ -101,7 +101,7 @@ public interface SyntheticObserverBuilder { * If not called, this synthetic observer will not be a transactional observer. * In other words, the default is {@link TransactionPhase#IN_PROGRESS}. *

      - * Note that transactional observers can't be asynchronous. If this synthetic observer + * Note that transactional observers cannot be asynchronous. If this synthetic observer * is configured to be both transactional and asynchronous, its registration will fail. * * @param transactionPhase the {@link TransactionPhase}, must not be {@code null} @@ -220,6 +220,28 @@ public interface SyntheticObserverBuilder { */ SyntheticObserverBuilder withParam(String key, String[] value); + /** + * Adds an enum-valued parameter to the map of event notification parameters. + * The parameter map is passed to the {@linkplain SyntheticObserver event notification} function + * when the event is fired. + * + * @param key the parameter key, must not be {@code null} + * @param value the parameter value + * @return this {@code SyntheticObserverBuilder} + */ + SyntheticObserverBuilder withParam(String key, Enum value); + + /** + * Adds an enum array-valued parameter to the map of event notification parameters. + * The parameter map is passed to the {@linkplain SyntheticObserver event notification} function + * when the event is fired. + * + * @param key the parameter key, must not be {@code null} + * @param value the parameter value + * @return this {@code SyntheticObserverBuilder} + */ + SyntheticObserverBuilder withParam(String key, Enum[] value); + /** * Adds a {@code Class}-valued parameter to the map of event notification parameters. * The parameter map is passed to the {@linkplain SyntheticObserver event notification} function @@ -230,7 +252,20 @@ public interface SyntheticObserverBuilder { * @return this {@code SyntheticObserverBuilder} */ SyntheticObserverBuilder withParam(String key, Class value); - // TODO add a variant that takes a `ClassInfo`? the value would be `Class` at runtime + + /** + * Adds a {@code Class}-valued parameter to the map of event notification parameters. + * The parameter map is passed to the {@linkplain SyntheticObserver event notification} function + * when the event is fired. + *

      + * When looked up from the parameter map in the event notification function, the value will be + * an instance of {@link Class}, not a {@code ClassInfo}. + * + * @param key the parameter key, must not be {@code null} + * @param value the parameter value + * @return this {@code SyntheticObserverBuilder} + */ + SyntheticObserverBuilder withParam(String key, ClassInfo value); /** * Adds a {@code Class} array-valued parameter to the map of event notification parameters. @@ -242,10 +277,23 @@ public interface SyntheticObserverBuilder { * @return this {@code SyntheticObserverBuilder} */ SyntheticObserverBuilder withParam(String key, Class[] value); - // TODO add a variant that takes a `ClassInfo[]`? the value would be `Class[]` at runtime /** - * Adds an {@code annotation}-valued parameter to the map of event notification parameters. + * Adds a {@code Class} array-valued parameter to the map of event notification parameters. + * The parameter map is passed to the {@linkplain SyntheticObserver event notification} function + * when the event is fired. + *

      + * When looked up from the parameter map in the event notification function, the values will be + * instances of {@link Class}, not {@code ClassInfo}. + * + * @param key the parameter key, must not be {@code null} + * @param value the parameter value + * @return this {@code SyntheticObserverBuilder} + */ + SyntheticObserverBuilder withParam(String key, ClassInfo[] value); + + /** + * Adds an annotation-valued parameter to the map of event notification parameters. * The parameter map is passed to the {@linkplain SyntheticObserver event notification} function * when the event is fired. *

      @@ -259,7 +307,7 @@ public interface SyntheticObserverBuilder { SyntheticObserverBuilder withParam(String key, AnnotationInfo value); /** - * Adds an {@code annotation}-valued parameter to the map of event notification parameters. + * Adds an annotation-valued parameter to the map of event notification parameters. * The parameter map is passed to the {@linkplain SyntheticObserver event notification} function * when the event is fired. * @@ -270,7 +318,7 @@ public interface SyntheticObserverBuilder { SyntheticObserverBuilder withParam(String key, Annotation value); /** - * Adds an {@code annotation} array-valued parameter to the map of event notification parameters. + * Adds an annotation array-valued parameter to the map of event notification parameters. * The parameter map is passed to the {@linkplain SyntheticObserver event notification} function * when the event is fired. *

      @@ -284,7 +332,7 @@ public interface SyntheticObserverBuilder { SyntheticObserverBuilder withParam(String key, AnnotationInfo[] value); /** - * Adds an {@code annotation} array-valued parameter to the map of event notification parameters. + * Adds an annotation array-valued parameter to the map of event notification parameters. * The parameter map is passed to the {@linkplain SyntheticObserver event notification} function * when the event is fired. * diff --git a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/Types.java b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/Types.java index 0be88815..9da6b252 100644 --- a/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/Types.java +++ b/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/Types.java @@ -55,8 +55,10 @@ public interface Types { * For primitives, use {@link #ofPrimitive(PrimitiveType.PrimitiveKind)}. For arrays, use {@link #ofArray(Type, int)}. * * @param name the binary name of the class, must not be {@code null} - * @return the {@link ClassType} or {@code null} if the type doesn't exist on the application classpath + * @return the {@link ClassType} or {@code null} if the type does not exist on the application classpath */ + // TODO using the term "classpath" here seems inappropriate; perhaps replace with "if the type is not present + // in any bean archive" or something like that? ClassType ofClass(String name); /** @@ -75,7 +77,7 @@ public interface Types { * @return the {@link ArrayType}, never {@code null} * @throws IllegalArgumentException if the element type is an array type */ - // TODO more error conditions? e.g. void array doesn't make sense either + // TODO more error conditions? e.g. void array does not make sense either ArrayType ofArray(Type elementType, int dimensions); /** @@ -87,7 +89,7 @@ public interface Types { * @param typeArguments one or more type arguments * @return the parameterized type, never {@code null} * @throws IllegalArgumentException if given {@code genericType} is not generic or if the number of type arguments - * doesn't match the number of type parameters declared by {@code genericType} + * does not match the number of type parameters declared by {@code genericType} */ ParameterizedType parameterized(Class genericType, Class... typeArguments); @@ -100,7 +102,7 @@ public interface Types { * @param typeArguments one or more type arguments * @return the parameterized type, never {@code null} * @throws IllegalArgumentException if given {@code genericType} is not generic or if the number of type arguments - * doesn't match the number of type parameters declared by {@code genericType} + * does not match the number of type parameters declared by {@code genericType} */ ParameterizedType parameterized(Class genericType, Type... typeArguments); @@ -113,7 +115,7 @@ public interface Types { * @param typeArguments one or more type arguments * @return the parameterized type, never {@code null} * @throws IllegalArgumentException if given {@code genericType} is not generic or if the number of type arguments - * doesn't match the number of type parameters declared by {@code genericType} + * does not match the number of type parameters declared by {@code genericType} */ ParameterizedType parameterized(ClassType genericType, Type... typeArguments); diff --git a/api/src/main/java/jakarta/enterprise/lang/model/AnnotationInfo.java b/api/src/main/java/jakarta/enterprise/lang/model/AnnotationInfo.java index 31f5f981..a8ee4947 100644 --- a/api/src/main/java/jakarta/enterprise/lang/model/AnnotationInfo.java +++ b/api/src/main/java/jakarta/enterprise/lang/model/AnnotationInfo.java @@ -60,7 +60,7 @@ default boolean isRepeatable() { * Returns the {@linkplain AnnotationMember value} of this annotation's member with given {@code name}. * * @param name member name, must not be {@code null} - * @return value of this annotation's member with given {@code name} or {@code null} if such member doesn't exist + * @return value of this annotation's member with given {@code name} or {@code null} if such member does not exist */ AnnotationMember member(String name); @@ -76,7 +76,7 @@ default boolean hasValue() { /** * Returns the {@linkplain AnnotationMember value} of this annotation's {@link AnnotationMember#VALUE value} member. * - * @return value of this annotation's {@link AnnotationMember#VALUE value} member or {@code null} if the member doesn't exist + * @return value of this annotation's {@link AnnotationMember#VALUE value} member or {@code null} if the member does not exist */ default AnnotationMember value() { return member(AnnotationMember.VALUE); diff --git a/api/src/main/java/jakarta/enterprise/lang/model/declarations/ClassInfo.java b/api/src/main/java/jakarta/enterprise/lang/model/declarations/ClassInfo.java index c0fa20cd..32db3214 100644 --- a/api/src/main/java/jakarta/enterprise/lang/model/declarations/ClassInfo.java +++ b/api/src/main/java/jakarta/enterprise/lang/model/declarations/ClassInfo.java @@ -53,7 +53,7 @@ public interface ClassInfo extends DeclarationInfo { /** * Returns a list of {@linkplain TypeVariable type parameters} declared on this class. - * Returns an empty list if this class isn't generic and so doesn't declare type parameters. + * Returns an empty list if this class is not generic and so does not declare type parameters. * * @return immutable list of this class's type parameters, never {@code null} */ @@ -61,7 +61,7 @@ public interface ClassInfo extends DeclarationInfo { /** * Returns the {@linkplain Type type} of this class's superclass. Returns {@code null} if this class - * doesn't have a superclass; that is, if this class is {@code java.lang.Object} or an interface. + * does not have a superclass; that is, if this class is {@code java.lang.Object} or an interface. * * @return the type of this class's superclass, or {@code null} if there's no superclass */ @@ -69,7 +69,7 @@ public interface ClassInfo extends DeclarationInfo { /** * Returns the {@linkplain ClassInfo declaration} of this class's superclass. Returns {@code null} if this class - * doesn't have a superclass; that is, if this class is {@code java.lang.Object} or an interface. + * does not have a superclass; that is, if this class is {@code java.lang.Object} or an interface. * * @return the declaration of this class's superclass, or {@code null} if there's no superclass */ diff --git a/api/src/main/java/jakarta/enterprise/lang/model/declarations/DeclarationInfo.java b/api/src/main/java/jakarta/enterprise/lang/model/declarations/DeclarationInfo.java index 558bd5b7..8bcdfb49 100644 --- a/api/src/main/java/jakarta/enterprise/lang/model/declarations/DeclarationInfo.java +++ b/api/src/main/java/jakarta/enterprise/lang/model/declarations/DeclarationInfo.java @@ -4,7 +4,7 @@ import jakarta.enterprise.lang.model.types.Type; /** - * Declarations directly correspond to an element of a program source code. + * A declaration is an element of a program source code. * Declarations are: * *

        diff --git a/api/src/main/java/jakarta/enterprise/lang/model/declarations/MethodInfo.java b/api/src/main/java/jakarta/enterprise/lang/model/declarations/MethodInfo.java index 8a1fb7ef..2191571a 100644 --- a/api/src/main/java/jakarta/enterprise/lang/model/declarations/MethodInfo.java +++ b/api/src/main/java/jakarta/enterprise/lang/model/declarations/MethodInfo.java @@ -33,18 +33,18 @@ public interface MethodInfo extends DeclarationInfo { /** * Returns the {@linkplain Type type} of the receiver parameter declared by this method. - * Returns {@code null} if this method can't declare a receiver parameter; that is, if this method + * Returns {@code null} if this method cannot declare a receiver parameter; that is, if this method * is {@code static} or is a constructor of a top-level class or a {@code static} nested class. - * If this method may declare a receiver parameter but doesn't, returns a {@link Type} with no annotations. + * If this method may declare a receiver parameter but does not, returns a {@link Type} with no annotations. * * @return the type of the receiver parameter declared by this method, with or without annotations, - * or {@code null} if this method can't declare a receiver parameter + * or {@code null} if this method cannot declare a receiver parameter */ Type receiverType(); /** * Returns a list of {@linkplain Type exception types} that are declared to be thrown by this method. - * Returns an empty list if this method doesn't declare any exception. + * Returns an empty list if this method does not declare any exception. * * @return immutable list of {@linkplain Type exception types}, never {@code null} */ @@ -52,7 +52,7 @@ public interface MethodInfo extends DeclarationInfo { /** * Returns a list of {@linkplain TypeVariable type parameters} declared on this method. - * Returns an empty list if this method isn't generic and so doesn't declare type parameters. + * Returns an empty list if this method is not generic and so does not declare type parameters. * * @return immutable list of {@linkplain TypeVariable type parameters}, never {@code null} */ diff --git a/api/src/main/java/jakarta/enterprise/lang/model/types/ArrayType.java b/api/src/main/java/jakarta/enterprise/lang/model/types/ArrayType.java index 1b3d0ef9..76261d2a 100644 --- a/api/src/main/java/jakarta/enterprise/lang/model/types/ArrayType.java +++ b/api/src/main/java/jakarta/enterprise/lang/model/types/ArrayType.java @@ -8,7 +8,7 @@ */ public interface ArrayType extends Type { // TODO this model (the element type + number of dimensions) might not be the best; - // specifically, it doesn't allow access to type-use annotations on component types + // specifically, it does not allow access to type-use annotations on component types // (for example: @C int @A [] @B [] f;) /** diff --git a/api/src/main/java/jakarta/enterprise/lang/model/types/ParameterizedType.java b/api/src/main/java/jakarta/enterprise/lang/model/types/ParameterizedType.java index 1384bbe9..9e1606c7 100644 --- a/api/src/main/java/jakarta/enterprise/lang/model/types/ParameterizedType.java +++ b/api/src/main/java/jakarta/enterprise/lang/model/types/ParameterizedType.java @@ -4,7 +4,7 @@ import java.util.List; /** - * A parameterized type. That is, a {@linkplain #declaration() generic class} together with + * A parameterized type. That is, a {@linkplain #genericClass() generic class} together with * a list of {@linkplain #typeArguments() type arguments}. The list of type arguments * has the same shape as the class's list of type parameters. * @@ -12,12 +12,12 @@ */ public interface ParameterizedType extends Type { /** - * Returns the {@linkplain ClassInfo declaration} of the generic class that was parameterized with a list + * Returns the {@linkplain ClassType type} of the generic class that was parameterized with a list * of type arguments to form this parameterized type. * - * @return the {@linkplain ClassInfo declaration} of the generic class, never {@code null} + * @return the {@linkplain ClassType type} of the generic class, never {@code null} */ - ClassInfo declaration(); + ClassType genericClass(); /** * Returns the list of type arguments that were applied to a generic class to form this parameterized type. @@ -26,6 +26,16 @@ public interface ParameterizedType extends Type { */ List typeArguments(); + /** + * Returns the {@linkplain ClassInfo declaration} of the {@linkplain #genericClass() generic class} + * that was parameterized with a list of type arguments to form this parameterized type. + * + * @return the {@linkplain ClassInfo declaration} of the generic class, never {@code null} + */ + default ClassInfo declaration() { + return genericClass().declaration(); + } + // --- @Override diff --git a/api/src/main/java/jakarta/enterprise/lang/model/types/Type.java b/api/src/main/java/jakarta/enterprise/lang/model/types/Type.java index 5caadd80..d51fd7a3 100644 --- a/api/src/main/java/jakarta/enterprise/lang/model/types/Type.java +++ b/api/src/main/java/jakarta/enterprise/lang/model/types/Type.java @@ -5,9 +5,20 @@ import jakarta.enterprise.lang.model.declarations.DeclarationInfo; /** - * A type is an abstract entity that may be used in a program, but doesn't necessarily have to - * correspond to a declaration in a program. Types that are declared in a program source code have a method - * to obtain the corresponding {@linkplain DeclarationInfo declaration}. + * A type is used in a program source code, but does not have to be declared anywhere. + *

        + * For example, the {@code int} type exists even if it is not declared in any Java source file, while + * the {@code java.lang.String} type is declared by the class of the same name. Array types, + * such as {@code int[]} or {@code String[][]}, are not declared anywhere either, but their + * element types may be. A generic class, such as {@code java.util.List}, declares a raw type + * of the same name, but it does not declare the parameterized types, such as {@code List}. + * Parameterized types are created by applying type arguments to generic classes. For example, + * the {@code List} type is created by applying {@code String} to {@code List}. + *

        + * Types occur on many places. A field has a type, a method has a return type, a method parameter + * has a type, even the {@code extends} clause in a class declaration contains a type. + * Occurences of types may be annotated. + *

        * Types are: * *

          @@ -19,6 +30,8 @@ *
        • a {@linkplain TypeVariable type variable}, such as {@code T} when used in a class that declares a type parameter {@code T}
        • *
        • a {@linkplain WildcardType wildcard} type, such as the type argument in {@code List}
        • *
        + * + * Class types and parameterized types allow obtaining their {@linkplain ClassInfo class declarations}. */ public interface Type extends AnnotationTarget { @Override diff --git a/api/src/main/java/jakarta/enterprise/lang/model/types/WildcardType.java b/api/src/main/java/jakarta/enterprise/lang/model/types/WildcardType.java index aaee3999..3116dcc2 100644 --- a/api/src/main/java/jakarta/enterprise/lang/model/types/WildcardType.java +++ b/api/src/main/java/jakarta/enterprise/lang/model/types/WildcardType.java @@ -14,17 +14,17 @@ public interface WildcardType extends Type { /** * Returns the upper bound of this wildcard type. - * Returns {@code null} if this wildcard type doesn't have an upper bound. + * Returns {@code null} if this wildcard type does not have an upper bound. * - * @return upper bound of this wildcard type, or {@code null} if this wildcard type doesn't have an upper bound + * @return upper bound of this wildcard type, or {@code null} if this wildcard type does not have an upper bound */ Type upperBound(); /** * Returns the lower bound of this wildcard type. - * Returns {@code null} if this wildcard type doesn't have a lower bound. + * Returns {@code null} if this wildcard type does not have a lower bound. * - * @return lower bound of this wildcard type, or {@code null} if this wildcard type doesn't have a lower bound + * @return lower bound of this wildcard type, or {@code null} if this wildcard type does not have a lower bound */ Type lowerBound();