From 26d082bb1ce2f7b253bcb864ac2b0eb8e2ab3a40 Mon Sep 17 00:00:00 2001 From: Thomas Vahrst Date: Fri, 13 Oct 2023 07:44:42 +0200 Subject: [PATCH] #291 moved @Order annotataions from bean classes to spring configurations --- .../springwolf/SpringwolfScannerConfiguration.java | 6 ++++++ .../operationdata/AbstractOperationDataScanner.java | 3 --- .../annotation/AsyncListenerAnnotationScanner.java | 3 --- .../annotation/AsyncPublisherAnnotationScanner.java | 3 --- .../asyncapi/amqp/SpringwolfAmqpScannerConfiguration.java | 4 ++++ .../annotation/ClassLevelRabbitListenerScanner.java | 3 --- .../annotation/MethodLevelRabbitListenerScanner.java | 3 --- 7 files changed, 10 insertions(+), 15 deletions(-) diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/SpringwolfScannerConfiguration.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/SpringwolfScannerConfiguration.java index d33118cf5..da0483786 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/SpringwolfScannerConfiguration.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/SpringwolfScannerConfiguration.java @@ -3,6 +3,7 @@ import io.github.stavshamir.springwolf.asyncapi.scanners.beans.BeanMethodsScanner; import io.github.stavshamir.springwolf.asyncapi.scanners.beans.DefaultBeanMethodsScanner; +import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelPriority; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.ConsumerOperationDataScanner; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.ProducerOperationDataScanner; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AsyncListenerAnnotationScanner; @@ -16,6 +17,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; import org.springframework.core.env.Environment; import java.util.List; @@ -50,6 +52,7 @@ public BeanMethodsScanner beanMethodsScanner(ConfigurationClassScanner configura @Bean @ConditionalOnProperty(name = SPRINGWOLF_SCANNER_CONSUMER_DATA_ENABLED, matchIfMissing = true) + @Order(value = ChannelPriority.MANUAL_DEFINED) public ConsumerOperationDataScanner consumerOperationDataScanner( AsyncApiDocketService asyncApiDocketService, SchemasService schemasService) { return new ConsumerOperationDataScanner(asyncApiDocketService, schemasService); @@ -57,6 +60,7 @@ public ConsumerOperationDataScanner consumerOperationDataScanner( @Bean @ConditionalOnProperty(name = SPRINGWOLF_SCANNER_PRODUCER_DATA_ENABLED, matchIfMissing = true) + @Order(value = ChannelPriority.MANUAL_DEFINED) public ProducerOperationDataScanner producerOperationDataScanner( AsyncApiDocketService asyncApiDocketService, SchemasService schemasService) { return new ProducerOperationDataScanner(asyncApiDocketService, schemasService); @@ -64,6 +68,7 @@ public ProducerOperationDataScanner producerOperationDataScanner( @Bean @ConditionalOnProperty(name = SPRINGWOLF_SCANNER_ASYNC_LISTENER_ENABLED, matchIfMissing = true) + @Order(value = ChannelPriority.ASYNC_ANNOTATION) public AsyncListenerAnnotationScanner asyncListenerAnnotationScanner( ComponentClassScanner componentClassScanner, SchemasService schemasService, @@ -75,6 +80,7 @@ public AsyncListenerAnnotationScanner asyncListenerAnnotationScanner( @Bean @ConditionalOnProperty(name = SPRINGWOLF_SCANNER_ASYNC_PUBLISHER_ENABLED, matchIfMissing = true) + @Order(value = ChannelPriority.ASYNC_ANNOTATION) public AsyncPublisherAnnotationScanner asyncPublisherAnnotationScanner( ComponentClassScanner componentClassScanner, SchemasService schemasService, diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/AbstractOperationDataScanner.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/AbstractOperationDataScanner.java index 4fafec7b3..dbcae7099 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/AbstractOperationDataScanner.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/AbstractOperationDataScanner.java @@ -5,7 +5,6 @@ import com.asyncapi.v2._6_0.model.channel.operation.Operation; import com.asyncapi.v2.binding.channel.ChannelBinding; import com.asyncapi.v2.binding.operation.OperationBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelPriority; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelsScanner; import io.github.stavshamir.springwolf.asyncapi.types.OperationData; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; @@ -14,7 +13,6 @@ import io.github.stavshamir.springwolf.schemas.SchemasService; import io.swagger.v3.oas.annotations.media.Schema; import lombok.extern.slf4j.Slf4j; -import org.springframework.core.annotation.Order; import org.springframework.util.StringUtils; import java.util.HashMap; @@ -28,7 +26,6 @@ import static java.util.stream.Collectors.toSet; @Slf4j -@Order(value = ChannelPriority.MANUAL_DEFINED) public abstract class AbstractOperationDataScanner implements ChannelsScanner { protected abstract SchemasService getSchemaService(); diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncListenerAnnotationScanner.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncListenerAnnotationScanner.java index 598fc7fa8..1b3a5ce51 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncListenerAnnotationScanner.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncListenerAnnotationScanner.java @@ -3,7 +3,6 @@ import com.asyncapi.v2.binding.message.MessageBinding; import com.asyncapi.v2.binding.operation.OperationBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelPriority; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.annotation.SpringPayloadAnnotationTypeExtractor; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.AbstractOperationDataScanner; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ComponentClassScanner; @@ -14,7 +13,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.context.EmbeddedValueResolverAware; -import org.springframework.core.annotation.Order; import org.springframework.util.StringValueResolver; import java.lang.reflect.Method; @@ -26,7 +24,6 @@ @Slf4j @RequiredArgsConstructor -@Order(value = ChannelPriority.ASYNC_ANNOTATION) public class AsyncListenerAnnotationScanner extends AbstractOperationDataScanner implements EmbeddedValueResolverAware { private StringValueResolver resolver; private final ComponentClassScanner componentClassScanner; diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncPublisherAnnotationScanner.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncPublisherAnnotationScanner.java index 7c2612f6d..a6a269ad6 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncPublisherAnnotationScanner.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncPublisherAnnotationScanner.java @@ -3,7 +3,6 @@ import com.asyncapi.v2.binding.message.MessageBinding; import com.asyncapi.v2.binding.operation.OperationBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelPriority; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.annotation.SpringPayloadAnnotationTypeExtractor; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.AbstractOperationDataScanner; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ComponentClassScanner; @@ -14,7 +13,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.context.EmbeddedValueResolverAware; -import org.springframework.core.annotation.Order; import org.springframework.util.StringValueResolver; import java.lang.reflect.Method; @@ -25,7 +23,6 @@ @Slf4j @RequiredArgsConstructor -@Order(value = ChannelPriority.ASYNC_ANNOTATION) public class AsyncPublisherAnnotationScanner extends AbstractOperationDataScanner implements EmbeddedValueResolverAware { private StringValueResolver resolver; diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/amqp/SpringwolfAmqpScannerConfiguration.java b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/amqp/SpringwolfAmqpScannerConfiguration.java index 0e31ab520..286875f40 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/amqp/SpringwolfAmqpScannerConfiguration.java +++ b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/amqp/SpringwolfAmqpScannerConfiguration.java @@ -1,6 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.stavshamir.springwolf.asyncapi.amqp; +import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelPriority; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.annotation.ClassLevelRabbitListenerScanner; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.annotation.MethodLevelRabbitListenerScanner; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.AmqpMessageBindingProcessor; @@ -13,6 +14,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; import java.util.List; @@ -26,6 +28,7 @@ public class SpringwolfAmqpScannerConfiguration { @Bean @ConditionalOnProperty(name = SPRINGWOLF_SCANNER_RABBIT_LISTENER_ENABLED, matchIfMissing = true) + @Order(value = ChannelPriority.AUTO_DISCOVERED) public ClassLevelRabbitListenerScanner classLevelRabbitListenerScanner( ComponentClassScanner componentClassScanner, SchemasService schemasService, @@ -37,6 +40,7 @@ public ClassLevelRabbitListenerScanner classLevelRabbitListenerScanner( @Bean @ConditionalOnProperty(name = SPRINGWOLF_SCANNER_RABBIT_LISTENER_ENABLED, matchIfMissing = true) + @Order(value = ChannelPriority.AUTO_DISCOVERED) public MethodLevelRabbitListenerScanner methodLevelRabbitListenerScanner( ComponentClassScanner componentClassScanner, SchemasService schemasService, diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/ClassLevelRabbitListenerScanner.java b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/ClassLevelRabbitListenerScanner.java index b4f0fb8c1..c60d37f5b 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/ClassLevelRabbitListenerScanner.java +++ b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/ClassLevelRabbitListenerScanner.java @@ -4,7 +4,6 @@ import com.asyncapi.v2.binding.channel.ChannelBinding; import com.asyncapi.v2.binding.message.MessageBinding; import com.asyncapi.v2.binding.operation.OperationBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelPriority; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelsScanner; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ComponentClassScanner; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.header.AsyncHeaders; @@ -16,7 +15,6 @@ import org.springframework.amqp.rabbit.annotation.RabbitHandler; import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.context.EmbeddedValueResolverAware; -import org.springframework.core.annotation.Order; import org.springframework.util.StringValueResolver; import java.lang.reflect.Method; @@ -24,7 +22,6 @@ import java.util.Map; @Slf4j -@Order(value = ChannelPriority.AUTO_DISCOVERED) public class ClassLevelRabbitListenerScanner extends AbstractClassLevelListenerScanner implements ChannelsScanner, EmbeddedValueResolverAware { diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelRabbitListenerScanner.java b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelRabbitListenerScanner.java index b07ffc5f8..0c123acf0 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelRabbitListenerScanner.java +++ b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelRabbitListenerScanner.java @@ -4,7 +4,6 @@ import com.asyncapi.v2.binding.channel.ChannelBinding; import com.asyncapi.v2.binding.message.MessageBinding; import com.asyncapi.v2.binding.operation.OperationBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelPriority; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelsScanner; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ComponentClassScanner; import io.github.stavshamir.springwolf.schemas.SchemasService; @@ -14,7 +13,6 @@ import org.springframework.amqp.core.Queue; import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.context.EmbeddedValueResolverAware; -import org.springframework.core.annotation.Order; import org.springframework.util.StringValueResolver; import java.lang.reflect.Method; @@ -22,7 +20,6 @@ import java.util.Map; @Slf4j -@Order(value = ChannelPriority.AUTO_DISCOVERED) public class MethodLevelRabbitListenerScanner extends AbstractMethodLevelListenerScanner implements ChannelsScanner, EmbeddedValueResolverAware {