/** * Add an annotation to the specified field. If the field is not already * present, it will be added. * * @param field the field to add the annotation to * @param annotation the annotation to add * @throws IllegalArgumentException if the annotation is null */ public AnnotatedTypeBuilder<X> addToField(AnnotatedField<? super X> field, Annotation annotation) { return addToField(field.getJavaMember(), annotation); }
/** * Add an annotation to the specified field. If the field is not already * present, it will be added. * * @param field the field to add the annotation to * @param annotation the annotation to add * @throws IllegalArgumentException if the annotation is null */ public AnnotatedTypeBuilder<X> addToField(AnnotatedField<? super X> field, Annotation annotation) { return addToField(field.getJavaMember(), annotation); }
/** * Add an annotation to the specified field. If the field is not already * present, it will be added. * * @param field the field to add the annotation to * @param annotation the annotation to add * @throws IllegalArgumentException if the annotation is null */ public AnnotatedTypeBuilder<X> addToField(AnnotatedField<? super X> field, Annotation annotation) { return addToField(field.getJavaMember(), annotation); }
public <T> void processAnnotatedType(@Observes ProcessAnnotatedType<T> pat) { boolean modified = false; AnnotatedType<T> annotatedType = pat.getAnnotatedType(); AnnotatedTypeBuilder<T> builder = new AnnotatedTypeBuilder<T>().readFromType(annotatedType); for (AnnotatedField field : annotatedType.getFields()) { Context context = field.getAnnotation(Context.class); if (context != null) { builder.addToField(field, new AnnotationLiteral<Inject>() {}); builder.addToField(field, new AnnotationLiteral<JaxRsQualifier>() {}); modified = true; } } if (modified) { pat.setAnnotatedType(builder.create()); } }
public <T> void processAnnotatedType(@Observes ProcessAnnotatedType<T> pat) { boolean modified = false; AnnotatedType<T> annotatedType = pat.getAnnotatedType(); AnnotatedTypeBuilder<T> builder = new AnnotatedTypeBuilder<T>().readFromType(annotatedType); for (AnnotatedField field : annotatedType.getFields()) { Context context = field.getAnnotation(Context.class); if (context != null) { builder.addToField(field, new AnnotationLiteral<Inject>() { }); builder.addToField(field, new AnnotationLiteral<JaxRsQualifier>() { }); modified = true; } } if (modified) { pat.setAnnotatedType(builder.create()); } }
public <T> void processAnnotatedType(@Observes ProcessAnnotatedType<T> pat) { boolean modified = false; AnnotatedType<T> annotatedType = pat.getAnnotatedType(); AnnotatedTypeBuilder<T> builder = new AnnotatedTypeBuilder<T>().readFromType(annotatedType); for (AnnotatedField field : annotatedType.getFields()) { Context context = field.getAnnotation(Context.class); if (context != null) { builder.addToField(field, new AnnotationLiteral<Inject>() { }); builder.addToField(field, new AnnotationLiteral<JaxRsQualifier>() { }); modified = true; } } if (modified) { pat.setAnnotatedType(builder.create()); } }
void applyQualifier(Annotation qual, AnnotatedTypeBuilder<?> atb) { AnnotatedType<?> at = atb.create(); //do a loop on all field to replace annotation mark by CDI annotations for (AnnotatedField af : at.getFields()) if (af.isAnnotationPresent(InjectWithQualifier.class)) { atb.addToField(af, InjectLiteral.instance); atb.addToField(af, qual); } //loop on constructors to do the same for (AnnotatedConstructor ac : at.getConstructors()) { Annotation[][] pa = ac.getJavaMember().getParameterAnnotations(); //loop on args to detect marked param for (int i = 0; i < pa.length; i++) for (int j = 0; j < pa[i].length; j++) if (pa[i][j].equals(InjectWithQualifierLiteral.instance)) { atb.addToConstructor(ac, InjectLiteral.instance); atb.addToConstructorParameter(ac.getJavaMember(), i, qual); } } //loop on other methods (setters) for (AnnotatedMethod am : at.getMethods()) if (am.isAnnotationPresent(InjectWithQualifierLiteral.class)) { atb.addToMethod(am, InjectLiteral.instance); atb.addToMethod(am, qual); } }
builder.addToField(field, new EjbName.EjbNameLiteral(beanNameOrName(ejb))); } else { builder.addToField(field, DefaultLiteral.INSTANCE); builder.addToField(field, new AnnotationLiteral<Inject>() { private static final long serialVersionUID = 1L; }); builder.addToField(field, new ResourceQualifier.ResourceQualifierLiteral(resource.name(), resource.lookup(), resource.mappedName()) { private static final long serialVersionUID = 1L;
Produces produces = field.getAnnotation(Produces.class); if (produces == null) { builder.addToField(field, new AnnotationLiteral<Inject>(){private static final long serialVersionUID = 1L;}); builder.addToField(field, EJbQualifierLiteral.INSTANCE); if (!ejb.beanName().isEmpty()) { builder.addToField(field,new EJbNameLiteral(ejb.beanName())); } else { builder.addToField(field, DefaultLiteral.INSTANCE);
Produces produces = field.getAnnotation(Produces.class); if (produces == null) { builder.addToField(field, new AnnotationLiteral<Inject>(){private static final long serialVersionUID = 1L;}); builder.addToField(field, EJbQualifierLiteral.INSTANCE); if (!ejb.beanName().isEmpty()) { builder.addToField(field,new EJbNameLiteral(ejb.beanName())); } else { builder.addToField(field, DefaultLiteral.INSTANCE);
builder.addToField(f, new DefaultBeanInformation.Literal(qualifiers)); Synthetic syntheticQualifier = producerSyntheticProvider.get(); builder.addToField(f, syntheticQualifier); producerToDeclaringDefaultBean.put(syntheticQualifier, new DefaultBeanQualifiers(declaringBeanSyntheticQualifier, declaringBeanQualifiers));