Interface MetaAnnotations
public interface MetaAnnotations
Allows registering custom CDI meta-annotations: qualifiers, interceptor bindings,
stereotypes, and scopes. When registering a custom scope, a context class must
also be provided.
- Since:
- 4.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addContext
(Class<? extends Annotation> scopeAnnotation, boolean isNormal, Class<? extends AlterableContext> contextClass) Registers custom context for givenscopeAnnotation
and givencontextClass
.void
addContext
(Class<? extends Annotation> scopeAnnotation, Class<? extends AlterableContext> contextClass) Registers custom context for givenscopeAnnotation
and givencontextClass
.addInterceptorBinding
(Class<? extends Annotation> annotation) Registersannotation
as an interceptor binding annotation.addQualifier
(Class<? extends Annotation> annotation) Registersannotation
as a qualifier annotation.addStereotype
(Class<? extends Annotation> annotation) Registersannotation
as a stereotype annotation.
-
Method Details
-
addQualifier
Registersannotation
as a qualifier annotation. Only makes sense if the annotation is not meta-annotated@Qualifier
.Returns a class configurator object that allows transforming meta-annotations on the
annotation
.- Parameters:
annotation
- annotation type- Returns:
- the class configurator, never
null
-
addInterceptorBinding
Registersannotation
as an interceptor binding annotation. Only makes sense if the annotation is not meta-annotated@InterceptorBinding
.Returns a class configurator object that allows transforming meta-annotations on the
annotation
.- Parameters:
annotation
- annotation type- Returns:
- the class configurator, never
null
-
addStereotype
Registersannotation
as a stereotype annotation. Only makes sense if the annotation is not meta-annotated@Stereotype
.Returns a class configurator object that allows transforming meta-annotations on the
annotation
.- Parameters:
annotation
- annotation type- Returns:
- the class configurator, never
null
-
addContext
void addContext(Class<? extends Annotation> scopeAnnotation, Class<? extends AlterableContext> contextClass) Registers custom context for givenscopeAnnotation
and givencontextClass
. CDI container will create an instance of the context class once to obtain the context object. The context class must bepublic
and have apublic
zero-parameter constructor; it must not be a bean.Whether the scope is normal is discovered from the scope annotation. This means that the scope annotation must be meta-annotated either
@NormalScope
or@Scope
.- Parameters:
scopeAnnotation
- the scope annotation type, must not benull
contextClass
- the context class, must not benull
- Throws:
IllegalArgumentException
- if thescopeAnnotation
is not meta-annotated@NormalScope
or@Scope
-
addContext
void addContext(Class<? extends Annotation> scopeAnnotation, boolean isNormal, Class<? extends AlterableContext> contextClass) Registers custom context for givenscopeAnnotation
and givencontextClass
. CDI container will create an instance of the context class once to obtain the context object. The context class must bepublic
and have apublic
zero-parameter constructor; it must not be a bean.The
isNormal
parameter determines whether the scope is a normal scope or a pseudo-scope.- Parameters:
scopeAnnotation
- the scope annotation type, must not benull
isNormal
- whether the scope is normalcontextClass
- the context class, must not benull
-