Skip to content

Commit

Permalink
#291 moved @order annotataions from bean classes to spring configurat…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
tvahrst committed Oct 13, 2023
1 parent 7e6f151 commit 26d082b
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -50,20 +52,23 @@ 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);
}

@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);
}

@Bean
@ConditionalOnProperty(name = SPRINGWOLF_SCANNER_ASYNC_LISTENER_ENABLED, matchIfMissing = true)
@Order(value = ChannelPriority.ASYNC_ANNOTATION)
public AsyncListenerAnnotationScanner asyncListenerAnnotationScanner(
ComponentClassScanner componentClassScanner,
SchemasService schemasService,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -25,7 +23,6 @@

@Slf4j
@RequiredArgsConstructor
@Order(value = ChannelPriority.ASYNC_ANNOTATION)
public class AsyncPublisherAnnotationScanner extends AbstractOperationDataScanner
implements EmbeddedValueResolverAware {
private StringValueResolver resolver;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand All @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,15 +15,13 @@
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;
import java.util.List;
import java.util.Map;

@Slf4j
@Order(value = ChannelPriority.AUTO_DISCOVERED)
public class ClassLevelRabbitListenerScanner extends AbstractClassLevelListenerScanner<RabbitListener, RabbitHandler>
implements ChannelsScanner, EmbeddedValueResolverAware {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -14,15 +13,13 @@
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;
import java.util.List;
import java.util.Map;

@Slf4j
@Order(value = ChannelPriority.AUTO_DISCOVERED)
public class MethodLevelRabbitListenerScanner extends AbstractMethodLevelListenerScanner<RabbitListener>
implements ChannelsScanner, EmbeddedValueResolverAware {

Expand Down

0 comments on commit 26d082b

Please sign in to comment.