use of io.quarkus.arc.processor.AnnotationsTransformer in project camel-quarkus by apache.
the class ConsumeProcessor method annotationsTransformers.
@BuildStep
void annotationsTransformers(BuildProducer<AnnotationsTransformerBuildItem> annotationsTransformers) {
annotationsTransformers.produce(new AnnotationsTransformerBuildItem(new AnnotationsTransformer() {
public boolean appliesTo(org.jboss.jandex.AnnotationTarget.Kind kind) {
return kind == Kind.CLASS;
}
@Override
public void transform(TransformationContext ctx) {
final ClassInfo classInfo = ctx.getTarget().asClass();
if (hasConsumeMethod(classInfo)) {
/* If there is @Consume on a method, make the declaring class a named injectable bean */
String beanName = namedValue(classInfo);
final Transformation transform = ctx.transform();
if (!classInfo.annotations().keySet().stream().anyMatch(BEAN_DEFINING_ANNOTATIONS::contains)) {
/* Only add @Singleton if there is no other bean defining annotation yet */
transform.add(Singleton.class);
}
if (beanName == null) {
beanName = ConsumeProcessor.uniqueBeanName(classInfo);
transform.add(Named.class, AnnotationValue.createStringValue("value", beanName));
}
transform.done();
}
}
}));
}
Aggregations