| 1 |
/* |
| 2 |
* Copyright (c) 2021 Red Hat and others |
| 3 |
* |
| 4 |
* This program and the accompanying materials are made available under the |
| 5 |
* Apache Software License 2.0 which is available at: |
| 6 |
* https://www.apache.org/licenses/LICENSE-2.0. |
| 7 |
* |
| 8 |
* SPDX-License-Identifier: Apache-2.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
package jakarta.enterprise.inject.build.compatible.spi; |
| 12 |
|
| 13 |
import java.lang.annotation.ElementType; |
| 14 |
import java.lang.annotation.Retention; |
| 15 |
import java.lang.annotation.RetentionPolicy; |
| 16 |
import java.lang.annotation.Target; |
| 17 |
|
| 18 |
/** |
| 19 |
* 3rd phase of {@linkplain BuildCompatibleExtension build compatible extension} execution. |
| 20 |
* Allows observing registered beans and observers. |
| 21 |
* <p> |
| 22 |
* This phase is executed twice. |
| 23 |
* For non-synthetic beans and observers, this phase is executed <em>before</em> {@linkplain Synthesis synthesis}. |
| 24 |
* For synthetic beans and observers, this phase is executed <em>after</em> synthesis. |
| 25 |
* <p> |
| 26 |
* In the following text, the term <em>expected types</em> denotes the set of types defined by |
| 27 |
* the {@link #types() types} member of the {@code @Registration} annotation. |
| 28 |
* <p> |
| 29 |
* Methods annotated {@code @Registration} must declare exactly one parameter of one of these types: |
| 30 |
* <ul> |
| 31 |
* <li>{@link BeanInfo}</li> |
| 32 |
* <li>{@link InterceptorInfo}</li> |
| 33 |
* <li>{@link ObserverInfo}</li> |
| 34 |
* </ul> |
| 35 |
* If a {@code @Registration} method has a parameter of type {@code BeanInfo}, the method is called once |
| 36 |
* for each bean whose set of bean types contains at least one <em>expected type</em>. |
| 37 |
* <p> |
| 38 |
* If the {@code @Registration} method has a parameter of type {@code InterceptorInfo}, the method is called once |
| 39 |
* for each interceptor whose set of bean types contains at least one <em>expected type</em>. |
| 40 |
* <p> |
| 41 |
* If the {@code @Registration} method has a parameter of type {@code ObserverInfo}, the method is called once |
| 42 |
* for each observer whose observed event type is assignable to at least one <em>expected type</em>. |
| 43 |
* <p> |
| 44 |
* Note that interceptors are beans, and {@code InterceptorInfo} is a subtype of {@code BeanInfo}, so if the method |
| 45 |
* has a parameter of type {@code BeanInfo}, it will be called for interceptors as well. |
| 46 |
* <p> |
| 47 |
* If the {@code @Registration} method doesn't declare any parameter of one of these types, |
| 48 |
* or if it declares more than one, the container treats it as a definition error. |
| 49 |
* <p> |
| 50 |
* Additionally, methods annotated {@code @Registration} may declare parameters of these types: |
| 51 |
* <ul> |
| 52 |
* <li>{@link Messages}</li> |
| 53 |
* <li>{@link Types}</li> |
| 54 |
* </ul> |
| 55 |
* |
| 56 |
* @since 4.0 |
| 57 |
*/ |
| 58 |
@Target(ElementType.METHOD) |
| 59 |
@Retention(RetentionPolicy.RUNTIME) |
| 60 |
public @interface Registration { |
| 61 |
/** |
| 62 |
* Defines the set of <em>expected types</em>. |
| 63 |
* |
| 64 |
* @return the set of <em>expected types</em> |
| 65 |
*/ |
| 66 |
Class<?>[] types(); |
| 67 |
} |