Anotação para o uso do CDI

1 resposta
jsfjava
D

estou criando um qualificador, só que estou com uma duvida

1 - Qual a diferença @InterceptorBiding x @Qualifier ?
2 - O que ela faz @Retention(RetentionPolicy.RUNTIME) ?

@InterceptorBinding
@Qualifier 
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME) 
public @interface Transactional {

 }

1 Resposta

D

Só dei uma olhada no javadoc
@Qualifier: Identifies qualifier annotations. Anyone can define a new qualifier. A qualifier annotation:
is annotated with @Qualifier, @Retention(RUNTIME), and typically @Documented.
can have attributes.
may be part of the public API, much like the dependency type, but unlike implementation types which needn’t be part of the public API.
may have restricted usage if annotated with @Target. While this specification covers applying qualifiers to fields and parameters only, some injector configurations might use qualifier annotations in other places (on methods or classes for example).

@InterceptorBinding: @Target(value=ANNOTATION_TYPE)

@Retention(value=RUNTIME)

@Documented

public @interface InterceptorBinding

Specifies that an annotation type is an interceptor binding type.
@Inherited

@InterceptorBinding

@Target({TYPE, METHOD, CONSTRUCTOR})

@Retention(RUNTIME)

public @interface Valid {}

Interceptor bindings are intermediate annotations that may be used to associate interceptors with target beans.

The interceptor bindings of an interceptor are specified by annotating the interceptor class with the binding types and the Interceptor annotation.

@Valid @Interceptor
public class ValidationInterceptor { … }

An interceptor may specify multiple interceptor bindings.

An interceptor binding of a bean may be declared by annotating the bean class, a method of the bean class, or a constructor of the bean class with the interceptor binding type.

Criado 6 de março de 2017
Ultima resposta 7 de mar. de 2017
Respostas 1
Participantes 2