Annotation Interface Registration
This phase is executed twice. For non-synthetic beans and observers, this phase is executed before 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 types member of the @Registration annotation.
Methods annotated @Registration must declare exactly one parameter of one of these types:
@Registration method has a parameter of type BeanInfo, the method is called once
for each bean whose set of bean types contains at least one expected type.
If the @Registration method has a parameter of type InterceptorInfo, the method is called once
for each interceptor whose set of bean types contains at least one expected type.
If the @Registration method has a parameter of type ObserverInfo, the method is called once
for each observer whose observed event type is assignable to at least one expected type.
Note that InterceptorInfo is a subtype of BeanInfo, so if the method has a parameter
of type BeanInfo, it will be called for interceptors as well.
If the @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 @Registration may declare parameters of these types:
- Since:
- 4.0
-
Required Element Summary
Required Elements
-
Element Details
-
types
Class<?>[] typesDefines the set of expected types. Any type is directly included in the set of expected types, unless it is a class type whose direct superclass type's erasure isTypeLiteral. In that case, the type argument toTypeLiteralis included in the set of expected types.If the type argument to
TypeLiteralcontains type variables, the container treats it as a definition error. (This restriction shall be lifted in the future, because@Dependentbeans may have type variables in their bean types. What it means for a set of bean types to contain an expected type is not immediately obvious in case type variables are present. More specification work is required.)If the direct superclass type is a raw
TypeLiteral, the container treats it as a definition error.For example, to observe all beans whose set of bean types contains the
CharSequencetype, you would write@Registration(types = CharSequence.class). To observe all beans whose set of bean types contains theList<CharSequence>type, you would write@Registration(types = ListOfCharSequence.class)whereListOfCharSequenceis defined as:static class ListOfCharSequence extends TypeLiteral<List<CharSequence>> { }- Returns:
- the set of expected types
-