Skip to content

Commit

Permalink
improve extension API documentation and resolve some open questions
Browse files Browse the repository at this point in the history
- renamed/moved `AnnotationInfo.MEMBER_VALUE` to `AnnotationMember.VALUE`
- replaced the phrase "component type" with "element type" when speaking
  about arrays, because JLS uses both and each has a different meaning
- removed `ContextConfig`, custom context registration is now fully
  handled in `MetaAnnotations`
- removed unnecessarily concrete language from `@SkipIfPortableExtensionPresent`
- methods in the `Types` class now have more specific return types
- implementations of `AnnotationInfo`, `AnnotationMember` and `AnnotationTarget`
  are now required to define `equals` and `hashCode`, and are explicitly
  not required to use a single object to represent a single construct
- the `ClassInfo` declaration is now required to return annotations
  `@Inherited` from a superclass, per `@Inherited` spec and CDI spec
- explicitly documented that `ClassInfo` doesn't provide access to nested
  classes or an enclosing class, and `PackageInfo` doesn't provide access
  to package members
- corrected some language to distinguish between generic classes (before
  type argument application) and parameterized types (after type argument
  application)
- specified meaning of `MethodInfo.name` and `returnType` for constructors,
  mirroring what reflection does (returning the declaring class)
- defined how implicit bounds are represented in `TypeVariable`
  and `WildcardType`
- removed `ObserverInfo.id()`
- usage of `Optional` was eliminated everywhere
- instead of "`void` type", we now always use "`void` pseudo-type"
- added `@since 4.0` tags everywhere
- changed `@link` tags to `@linkplain` if the link text isn't an identifier
  • Loading branch information
Ladicek committed Aug 20, 2021
1 parent fc5f209 commit 2d14e87
Show file tree
Hide file tree
Showing 51 changed files with 774 additions and 396 deletions.

Large diffs are not rendered by default.

Expand Up @@ -5,8 +5,10 @@
import java.lang.annotation.Annotation;

/**
* Service provider interface that supports creating {@link AnnotationBuilder}.
* Supports instantiating {@link AnnotationBuilder}.
* Should not be called directly by users; the static methods on {@link AnnotationBuilder} are preferred.
*
* @since 4.0
*/
public interface AnnotationBuilderFactory {
/**
Expand Down
Expand Up @@ -8,18 +8,34 @@
import java.util.Collection;

/**
* Provides read-only information about a bean.
* Beans are:
*
* <ul>
* <li>managed beans</li>
* <li>beans defined by producer methods</li>
* <li>beans defined by producer fields</li>
* <li>synthetic beans</li>
* </ul>
*
* Managed beans are also known as class-based beans, while beans defined by producer methods
* and producer fields are together also known as producer-based beans.
* <p>
* Class-based and producer-based beans directly correspond to a declaration in program source code.
* Synthetic beans don't and are instead defined through other mechanisms, such as
* {@linkplain BuildCompatibleExtension extensions}.
*
* @since 4.0
*/
public interface BeanInfo {
/**
* Returns the {@link ScopeInfo scope} of this bean.
* Returns the {@linkplain ScopeInfo scope} of this bean.
*
* @return the {@link ScopeInfo scope} of this bean, never {@code null}
* @return the {@linkplain ScopeInfo scope} of this bean, never {@code null}
*/
ScopeInfo scope();

/**
* Returns a collection of all {@link Type type}s of this bean.
* Returns a collection of all {@linkplain Type types} of this bean.
*
* @return immutable collection of bean types, never {@code null}
*/
Expand All @@ -44,7 +60,7 @@ public interface BeanInfo {
ClassInfo declaringClass();

/**
* Returns whether this bean is a managed bean, sometimes also called class-based bean.
* Returns whether this bean is a managed bean, also known as class-based bean.
*
* @return whether this bean is a managed bean
*/
Expand All @@ -66,43 +82,44 @@ public interface BeanInfo {

/**
* Returns whether this bean is synthetic. In other words, whether this bean
* doesn't correspond to a declaration in some source code and was created
* doesn't 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
*/
boolean isSynthetic();

/**
* Returns the producer {@link MethodInfo method} that defines this bean.
* Returns the producer {@linkplain MethodInfo method} that defines this bean.
* Returns {@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 isn't defined by a producer method
*/
MethodInfo producerMethod();

/**
* Returns the producer {@link FieldInfo field} that defines this bean.
* Returns the producer {@linkplain FieldInfo field} that defines this bean.
* Returns {@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 isn't defined by a producer field
*/
FieldInfo producerField();

/**
* Returns whether this bean is an {@link jakarta.enterprise.inject.Alternative alternative}.
* Returns whether this bean is an {@linkplain jakarta.enterprise.inject.Alternative alternative}.
*
* @return whether this bean is an {@link jakarta.enterprise.inject.Alternative alternative}
* @return whether this bean is an {@linkplain jakarta.enterprise.inject.Alternative alternative}
*/
boolean isAlternative();

/**
* Returns the {@link jakarta.annotation.Priority priority} of this alternative bean.
* Returns the {@linkplain jakarta.annotation.Priority priority} of this alternative bean.
* If this bean is not an alternative, the return value is undefined.
*
* @return the priority of this alternative bean
* @see #isAlternative()
*/
// TODO maybe specify that if this bean is not an alternative, this returns 0?
int priority();

/**
Expand All @@ -115,16 +132,16 @@ public interface BeanInfo {
String getName();

/**
* Returns the {@link DisposerInfo disposer method} of this producer-based bean.
* 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.
*
* @return the {@link DisposerInfo disposer}, or {@code null} if this bean doesn't have a disposer
* @return the {@linkplain DisposerInfo disposer}, or {@code null} if this bean doesn't have a disposer
*/
DisposerInfo disposer();

/**
* Returns a collection of this bean's {@link StereotypeInfo stereotype}s.
* Returns a collection of this bean's {@linkplain StereotypeInfo stereotypes}.
*
* @return immutable collection of stereotypes, never {@code null}
*/
Expand All @@ -133,7 +150,7 @@ public interface BeanInfo {
// TODO interceptors?

/**
* Returns a collection of this bean's {@link InjectionPointInfo injection point}s.
* Returns a collection of this bean's {@linkplain InjectionPointInfo injection points}.
*
* @return immutable collection of injection points, never {@code null}
*/
Expand Down
Expand Up @@ -29,6 +29,8 @@
* <p>
* Extension classes can be annotated {@link SkipIfPortableExtensionPresent @SkipIfPortablExtensionPresent}
* when they are supposed to be ignored in presence of a given portable extension.
*
* @since 4.0
*/
public interface BuildCompatibleExtension {
// TODO rename? "build compatible" is too long; ideally, we'd have a single word that describes
Expand Down
Expand Up @@ -3,11 +3,13 @@
import jakarta.enterprise.inject.spi.Prioritized;

/**
* Service facade for various services needed by {@link BuildCompatibleExtension} implementations.
* Service provider interface for various services needed by {@link BuildCompatibleExtension} implementations.
*
* @since 4.0
*/
public interface BuildServices extends Prioritized {
/**
* @return The {@link AnnotationBuilderFactory} instance, never {@code null}
* @return the {@link AnnotationBuilderFactory} instance, never {@code null}
*/
AnnotationBuilderFactory annotationBuilderFactory();
}
Expand Up @@ -10,10 +10,14 @@
* are only seen by the CDI container.
*
* @see Enhancement
* @since 4.0
*/
public interface ClassConfig extends DeclarationConfig<ClassConfig> {
// TODO now that ClassInfo also returns inherited annotations, need to think about what happens
// when we add an annotation that collides with an inherited one, or when we remove an inherited annotation

/**
* Returns the {@link ClassInfo read-only information} about this transformed class.
* Returns the {@link ClassInfo} corresponding to this transformed class.
*
* @return the {@link ClassInfo} corresponding to this transformed class, never {@code null}
*/
Expand All @@ -25,22 +29,22 @@ public interface ClassConfig extends DeclarationConfig<ClassConfig> {
*
* @return immutable collection of {@link MethodConfig} objects, never {@code null}
*/
// TODO specify whether inherited constructors are also included
// TODO specify whether inherited constructors are also included; probably mirror what ClassInfo does
Collection<MethodConfig> constructors();

/**
* Returns a collection of {@link MethodConfig} objects for each method of this class.
*
* @return immutable collection of {@link MethodConfig} objects, never {@code null}
*/
// TODO specify whether inherited methods are also included
// TODO specify whether inherited methods are also included; probably mirror what ClassInfo does
Collection<MethodConfig> methods();

/**
* Returns a collection of {@link FieldConfig} objects for each field of this class.
*
* @return immutable collection of {@link FieldConfig} objects, never {@code null}
*/
// TODO specify whether inherited fields are also included
// TODO specify whether inherited fields are also included; probably mirror what ClassInfo does
Collection<FieldConfig> fields();
}

This file was deleted.

Expand Up @@ -12,10 +12,11 @@
* are only seen by the CDI container.
*
* @see Enhancement
* @since 4.0
*/
public interface DeclarationConfig<THIS extends DeclarationConfig<THIS>> {
/**
* Returns the {@link DeclarationInfo read-only information} about this transformed declaration.
* Returns the {@link DeclarationInfo} corresponding to this transformed declaration.
*
* @return the {@link DeclarationInfo} corresponding to this transformed declaration, never {@code null}
*/
Expand Down
Expand Up @@ -14,9 +14,11 @@
* <ul>
* <li>{@link ScannedClasses}: to register classes to be scanned during bean discovery</li>
* <li>{@link MetaAnnotations}: to register custom meta-annotations:
* qualifiers, interceptor bindings, stereotypes and scopes</li>
* qualifiers, interceptor bindings, stereotypes and scopes</li>
* <li>{@link Messages}: to produce log messages and validation errors</li>
* </ul>
*
* @since 4.0
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
Expand Down
Expand Up @@ -4,20 +4,23 @@
import jakarta.enterprise.lang.model.declarations.ParameterInfo;

/**
* Provides read-only information about a disposer method.
* Disposer methods may exist for producer-based beans. Each disposer method
* has a {@linkplain #disposedParameter() disposed parameter}.
*
* @since 4.0
*/
public interface DisposerInfo {
/**
* Returns this disposer method represented as {@link MethodInfo}.
* Returns the {@linkplain MethodInfo declaration} of this disposer method.
*
* @return the {@link MethodInfo}, never {@code null}
* @return the {@linkplain MethodInfo declaration} of this disposer method, never {@code null}
*/
MethodInfo disposerMethod();

/**
* Returns the disposed parameter of this disposer method.
* Returns the {@linkplain ParameterInfo declaration} of the disposed parameter of this disposer method.
*
* @return the disposed parameter, never {@code null}
* @return the {@linkplain ParameterInfo declaration} of the disposed parameter of this disposer method, never {@code null}
*/
ParameterInfo disposedParameter();
}
Expand Up @@ -21,11 +21,13 @@
* You can also declare a parameter of type {@link Messages Messages} to produce log messages and validation errors.
* <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 type, primitive types,
* 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.
* <p>
* If you need to create instances of {@link jakarta.enterprise.lang.model.AnnotationInfo AnnotationInfo},
* use {@link AnnotationBuilder}.
*
* @since 4.0
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
Expand Down
Expand Up @@ -23,6 +23,8 @@
* If the {@code annotatedWith} attribute is set, only types that use given annotations are considered.
* The annotations can appear on the type, or on any member of the type, or any parameter of any member of the type.
* This is ignored for {@code @Processing}.
*
* @since 4.0
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
Expand Down
Expand Up @@ -8,10 +8,11 @@
* are only seen by the CDI container.
*
* @see Enhancement
* @since 4.0
*/
public interface FieldConfig extends DeclarationConfig<FieldConfig> {
/**
* Returns the {@link FieldInfo read-only information} about this transformed field.
* Returns the {@link FieldInfo} corresponding to this transformed field.
*
* @return the {@link FieldInfo} corresponding to this transformed field, never {@code null}
*/
Expand Down
Expand Up @@ -6,7 +6,10 @@
import java.util.Collection;

/**
* Provides read-only information about an injection point.
* An injection point defined on some bean. Injection points may be fields
* or method parameters.
*
* @since 4.0
*/
public interface InjectionPointInfo {
/**
Expand Down
Expand Up @@ -5,6 +5,8 @@
/**
* Allows logging and producing errors during {@link BuildCompatibleExtension} execution.
* If an error is produced, application deployment will fail.
*
* @since 4.0
*/
public interface Messages {
/**
Expand Down

0 comments on commit 2d14e87

Please sign in to comment.