use of io.quarkus.arc.processor.AnnotationStore in project quarkus by quarkusio.
the class SpringScheduledProcessor method collectScheduledMethods.
@BuildStep
void collectScheduledMethods(BeanRegistrationPhaseBuildItem beanRegistrationPhase, BuildProducer<ScheduledBusinessMethodItem> scheduledBusinessMethods) {
AnnotationStore annotationStore = beanRegistrationPhase.getContext().get(BuildExtension.Key.ANNOTATION_STORE);
for (BeanInfo bean : beanRegistrationPhase.getContext().beans().classBeans()) {
ClassInfo classInfo = bean.getTarget().get().asClass();
for (MethodInfo method : classInfo.methods()) {
List<AnnotationInstance> schedules = null;
AnnotationInstance scheduledAnnotation = annotationStore.getAnnotation(method, SPRING_SCHEDULED);
if (scheduledAnnotation != null) {
schedules = Collections.singletonList(scheduledAnnotation);
} else {
AnnotationInstance schedulesAnnotation = annotationStore.getAnnotation(method, SPRING_SCHEDULES);
if (schedulesAnnotation != null) {
schedules = new ArrayList<>();
for (AnnotationInstance scheduledInstance : schedulesAnnotation.value().asNestedArray()) {
schedules.add(AnnotationInstance.create(scheduledInstance.name(), schedulesAnnotation.target(), scheduledInstance.values()));
}
}
}
processSpringScheduledAnnotation(scheduledBusinessMethods, bean, method, schedules);
}
}
}
use of io.quarkus.arc.processor.AnnotationStore in project quarkus by quarkusio.
the class VertxProcessor method collectEventConsumers.
@BuildStep
void collectEventConsumers(BeanRegistrationPhaseBuildItem beanRegistrationPhase, BuildProducer<EventConsumerBusinessMethodItem> messageConsumerBusinessMethods, BuildProducer<BeanConfiguratorBuildItem> errors) {
// We need to collect all business methods annotated with @ConsumeEvent first
AnnotationStore annotationStore = beanRegistrationPhase.getContext().get(BuildExtension.Key.ANNOTATION_STORE);
for (BeanInfo bean : beanRegistrationPhase.getContext().beans().classBeans()) {
for (MethodInfo method : bean.getTarget().get().asClass().methods()) {
AnnotationInstance consumeEvent = annotationStore.getAnnotation(method, CONSUME_EVENT);
if (consumeEvent != null) {
// Validate method params and return type
List<Type> params = method.parameters();
if (params.size() != 1) {
throw new IllegalStateException(String.format("An event consumer business method must accept exactly one parameter: %s [method: %s, bean:%s]", params, method, bean));
}
if (method.returnType().kind() != Kind.VOID && VertxConstants.isMessage(params.get(0).name())) {
throw new IllegalStateException(String.format("An event consumer business method that accepts io.vertx.core.eventbus.Message or io.vertx.mutiny.core.eventbus.Message must return void [method: %s, bean:%s]", method, bean));
}
messageConsumerBusinessMethods.produce(new EventConsumerBusinessMethodItem(bean, method, consumeEvent));
LOGGER.debugf("Found event consumer business method %s declared on %s", method, bean);
}
}
}
}
Aggregations