jakarta.enterprise.inject.build.compatible.spi.Registration Maven / Gradle / Ivy
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;
/**
* 3rd phase of {@linkplain BuildCompatibleExtension build compatible extension} execution.
* Allows observing registered beans and observers.
*
* This phase is executed twice.
* For non-synthetic beans and observers, this phase is executed before {@linkplain Synthesis synthesis}.
* For synthetic beans and observers, this phase is executed after synthesis.
*
* In the following text, the term expected types denotes the set of types defined by
* the {@link #types() types} member of the {@code @Registration} annotation.
*
* Methods annotated {@code @Registration} must declare exactly one parameter of one of these types:
*
* - {@link BeanInfo}
* - {@link InterceptorInfo}
* - {@link ObserverInfo}
*
* If a {@code @Registration} 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 expected type.
*
* If the {@code @Registration} 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 expected type.
*
* If the {@code @Registration} method has a parameter of type {@code ObserverInfo}, the method is called once
* for each observer whose observed event type is assignable to at least one expected type.
*
* 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.
*
* If the {@code @Registration} method doesn't declare any parameter of one of these types,
* or if it declares more than one, the container treats it as a definition error.
*
* Additionally, methods annotated {@code @Registration} may declare parameters of these types:
*
* - {@link Messages}
* - {@link Types}
*
*
* @since 4.0
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Registration {
/**
* Defines the set of expected types.
*
* @return the set of expected types
*/
Class>[] types();
}