From 182b13c413448f886b4ff60f7d0f08f8ea3f2240 Mon Sep 17 00:00:00 2001 From: Timon Back Date: Fri, 13 Oct 2023 16:18:39 +0200 Subject: [PATCH] feat(core): add AsyncGenericBinding (#370) * feat(core): add AsyncGenericBinding * feat(core): refine AsyncGenericOperationBinding * feat(core): improve example * feat(core): add BindingProcessorPriority * feat(core): handle multiple bindings with same type Removed AsyncGenericOperationBinding * refactor(core): move binding processors to binding package Leave public annotations in current package to avoid breaking changes * feat(generic-binding): Move `@AsyncGenericOperationBinding` to own addon * feat(generic-binding): Update README.md * chore(generic-binding): fixup * chore(generic-binding): fixup * refactor(generic-binding): Use spring configuration * feat(generic-binding): Improve sqs example (overwrite existing binding) * chore(generic-binding): move to package addons * chore(generic-binding): spotless * chore(generic-binding): spotless * chore(generic-binding): move to addons package * chore(generic-binding): move to addons package * chore(generic-binding): move to generic_binding package * chore(generic-binding): add to sns plugin * chore(common-model-converters): fix auto configuration path * chore(generic-binding): fix log formatting * chore(gh): Run full matrix, do not abort early * test(sqs): update asyncapi.json (temporary output) Co-authored-by: sam0r040 <93372330+sam0r040@users.noreply.github.com> --- ...l-converters.yml => springwolf-addons.yml} | 13 +- .github/workflows/springwolf-plugins.yml | 1 + README.md | 13 +- build.gradle | 3 +- settings.gradle | 3 +- .../README.md | 2 +- .../src/main/java/.gitkeep | 0 ...ommonModelConvertersAutoConfiguration.java | 4 +- .../monetaryamount/MonetaryAmount.java | 2 +- .../MonetaryAmountConverter.java | 2 +- ...ot.autoconfigure.AutoConfiguration.imports | 2 +- .../src/test/java/.gitkeep | 0 .../MonetaryAmountConverterTest.java | 4 +- .../springwolf-generic-binding/README.md | 48 ++++++ .../springwolf-generic-binding/build.gradle | 51 +++++++ .../AsyncGenericOperationBinding.java | 30 ++++ ...SpringwolfGenericBindingConfiguration.java | 18 +++ ...AsyncGenericOperationBindingProcessor.java | 28 ++++ .../annotation/processor/PropertiesUtil.java | 55 +++++++ ...ot.autoconfigure.AutoConfiguration.imports | 1 + ...cGenericOperationBindingProcessorTest.java | 138 ++++++++++++++++++ .../SpringwolfScannerConfiguration.java | 4 +- .../bindings/BindingProcessorPriority.java | 32 ++++ .../MessageBindingProcessor.java | 5 +- .../OperationBindingProcessor.java | 5 +- .../ProcessedMessageBinding.java | 2 +- .../ProcessedOperationBinding.java | 2 +- .../AbstractOperationBindingProcessor.java | 34 ++++- .../AsyncAnnotationScannerUtil.java | 12 +- .../AsyncListenerAnnotationScanner.java | 2 + .../AsyncPublisherAnnotationScanner.java | 2 + ...TestAbstractOperationBindingProcessor.java | 20 ++- .../TestMessageBindingProcessor.java | 8 +- .../TestOperationBindingProcessor.java | 20 ++- .../AsyncAnnotationScannerUtilTest.java | 51 ++++++- ...tenerAnnotationScannerIntegrationTest.java | 1 + ...isherAnnotationScannerIntegrationTest.java | 1 + .../springwolf-sqs-example/build.gradle | 1 + .../sqs/producers/AnotherProducer.java | 4 + .../SpringwolfAmqpScannerConfiguration.java | 7 +- .../AmqpMessageBindingProcessor.java | 5 +- .../AmqpOperationBindingProcessor.java | 4 +- .../SpringwolfKafkaScannerConfiguration.java | 7 +- .../KafkaMessageBindingProcessor.java | 5 +- .../KafkaOperationBindingProcessor.java | 4 +- .../SnsMessageBindingProcessor.java | 3 +- .../SnsOperationBindingProcessor.java | 3 +- .../SpringwolfSnsScannerConfiguration.java | 4 + .../SqsMessageBindingProcessor.java | 5 +- .../SqsOperationBindingProcessor.java | 4 +- .../SpringwolfSqsScannerConfiguration.java | 7 +- 51 files changed, 608 insertions(+), 74 deletions(-) rename .github/workflows/{springwolf-common-model-converters.yml => springwolf-addons.yml} (85%) delete mode 100644 springwolf-add-ons/springwolf-common-model-converters/src/main/java/.gitkeep rename springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/{common_converters => addons/common_model_converters}/configuration/CommonModelConvertersAutoConfiguration.java (70%) rename springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/{common_converters => addons/common_model_converters}/converters/monetaryamount/MonetaryAmount.java (79%) rename springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/{common_converters => addons/common_model_converters}/converters/monetaryamount/MonetaryAmountConverter.java (90%) delete mode 100644 springwolf-add-ons/springwolf-common-model-converters/src/test/java/.gitkeep rename springwolf-add-ons/springwolf-common-model-converters/src/test/java/io/github/stavshamir/springwolf/{common_converters => addons/common_model_converters}/converters/MonetaryAmountConverterTest.java (86%) create mode 100644 springwolf-add-ons/springwolf-generic-binding/README.md create mode 100644 springwolf-add-ons/springwolf-generic-binding/build.gradle create mode 100644 springwolf-add-ons/springwolf-generic-binding/src/main/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/AsyncGenericOperationBinding.java create mode 100644 springwolf-add-ons/springwolf-generic-binding/src/main/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/configuration/SpringwolfGenericBindingConfiguration.java create mode 100644 springwolf-add-ons/springwolf-generic-binding/src/main/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/processor/AsyncGenericOperationBindingProcessor.java create mode 100644 springwolf-add-ons/springwolf-generic-binding/src/main/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/processor/PropertiesUtil.java create mode 100644 springwolf-add-ons/springwolf-generic-binding/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 springwolf-add-ons/springwolf-generic-binding/src/test/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/processor/AsyncGenericOperationBindingProcessorTest.java create mode 100644 springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/BindingProcessorPriority.java rename springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/{channels/operationdata/annotation => bindings}/MessageBindingProcessor.java (72%) rename springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/{channels/operationdata/annotation => bindings}/OperationBindingProcessor.java (72%) rename springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/{channels/operationdata => bindings}/ProcessedMessageBinding.java (74%) rename springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/{channels/operationdata => bindings}/ProcessedOperationBinding.java (74%) rename springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/{channels => bindings/processor}/AbstractOperationBindingProcessor.java (53%) rename springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/{channels/operationdata/annotation => bindings/processor}/TestAbstractOperationBindingProcessor.java (54%) rename springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/{channels/operationdata/annotation => bindings/processor}/TestMessageBindingProcessor.java (74%) rename springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/{channels/operationdata/annotation => bindings/processor}/TestOperationBindingProcessor.java (50%) rename springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/{channels/operationdata => bindings/processor}/AmqpMessageBindingProcessor.java (84%) rename springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/{channels/operationdata => bindings/processor}/AmqpOperationBindingProcessor.java (86%) rename springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/{channels/operationdata => bindings/processor}/KafkaMessageBindingProcessor.java (91%) rename springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/{channels/operationdata => bindings/processor}/KafkaOperationBindingProcessor.java (89%) rename springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/{channels/operationdata => bindings/processor}/SqsMessageBindingProcessor.java (84%) rename springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/{channels/operationdata => bindings/processor}/SqsOperationBindingProcessor.java (75%) diff --git a/.github/workflows/springwolf-common-model-converters.yml b/.github/workflows/springwolf-addons.yml similarity index 85% rename from .github/workflows/springwolf-common-model-converters.yml rename to .github/workflows/springwolf-addons.yml index 77dc641eb..17589d651 100644 --- a/.github/workflows/springwolf-common-model-converters.yml +++ b/.github/workflows/springwolf-addons.yml @@ -1,4 +1,4 @@ -name: springwolf-common-model-converters +name: springwolf-addons on: push: @@ -7,14 +7,19 @@ on: pull_request: types: [ opened, synchronize, ready_for_review ] -env: - addon: springwolf-add-ons/springwolf-common-model-converters - jobs: build: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + addon: [ "common-model-converters", "generic-binding" ] + + env: + addon: springwolf-add-ons/springwolf-${{ matrix.addon }} + steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/springwolf-plugins.yml b/.github/workflows/springwolf-plugins.yml index eafe868c0..69e087fe1 100644 --- a/.github/workflows/springwolf-plugins.yml +++ b/.github/workflows/springwolf-plugins.yml @@ -13,6 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: plugin: [ "amqp", "cloud-stream", "kafka", "sns", "sqs" ] diff --git a/README.md b/README.md index 788181067..9dda5a233 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,10 @@ **Automated documentation for event-driven applications built with Spring Boot** [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -![springwolf-core](https://github.com/springwolf/springwolf-core/workflows/springwolf-core/badge.svg) -![springwolf-amqp](https://github.com/springwolf/springwolf-core/workflows/springwolf-amqp/badge.svg) -![springwolf-cloud-stream](https://github.com/springwolf/springwolf-core/workflows/springwolf-cloud-stream/badge.svg) -![springwolf-kafka](https://github.com/springwolf/springwolf-core/workflows/springwolf-kafka/badge.svg) -![springwolf-sns](https://github.com/springwolf/springwolf-core/workflows/springwolf-sns/badge.svg) -![springwolf-sqs](https://github.com/springwolf/springwolf-core/workflows/springwolf-sqs/badge.svg) -![springwolf-common-model-converters](https://github.com/springwolf/springwolf-core/actions/workflows/springwolf-common-model-converters.yml/badge.svg) - +[![springwolf-core](https://github.com/springwolf/springwolf-core/actions/workflows/springwolf-core.yml/badge.svg)](https://github.com/springwolf/springwolf-core/actions/workflows/springwolf-core.yml) +[![springwolf-ui](https://github.com/springwolf/springwolf-core/actions/workflows/springwolf-ui.yml/badge.svg)](https://github.com/springwolf/springwolf-core/actions/workflows/springwolf-ui.yml) +[![springwolf-plugins](https://github.com/springwolf/springwolf-core/actions/workflows/springwolf-plugins.yml/badge.svg)](https://github.com/springwolf/springwolf-core/actions/workflows/springwolf-plugins.yml) +[![springwolf-addons](https://github.com/springwolf/springwolf-core/actions/workflows/springwolf-addons.yml/badge.svg)](https://github.com/springwolf/springwolf-core/actions/workflows/springwolf-addons.yml) > We are on discord for any question, discussion, request etc. > Join us at https://discord.gg/HZYqd5RPTd @@ -66,6 +62,7 @@ More details in the documentation. | [Cloud Stream](https://github.com/springwolf/springwolf-core/tree/master/springwolf-plugins/springwolf-cloud-stream-plugin) | [Cloud Stream Example](https://github.com/springwolf/springwolf-core/tree/master/springwolf-examples/springwolf-cloud-stream-example) | ![Maven Central](https://img.shields.io/maven-central/v/io.github.springwolf/springwolf-cloud-stream?color=green&label=springwolf-cloud-stream&style=plastic) | ![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/io.github.springwolf/springwolf-cloud-stream?label=springwolf-cloud-stream&server=https%3A%2F%2Fs01.oss.sonatype.org&style=plastic) | | [Kafka](https://github.com/springwolf/springwolf-core/tree/master/springwolf-plugins/springwolf-kafka-plugin) | [Kafka Example](https://github.com/springwolf/springwolf-core/tree/master/springwolf-examples/springwolf-kafka-example) | ![Maven Central](https://img.shields.io/maven-central/v/io.github.springwolf/springwolf-kafka?color=green&label=springwolf-kafka&style=plastic) | ![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/io.github.springwolf/springwolf-kafka?label=springwolf-kafka&server=https%3A%2F%2Fs01.oss.sonatype.org&style=plastic) | | [Common Model Converter](https://github.com/springwolf/springwolf-core/tree/master/springwolf-add-ons/springwolf-common-model-converters) | | ![Maven Central](https://img.shields.io/maven-central/v/io.github.springwolf/springwolf-common-model-converters?color=green&label=springwolf-common-model-converters&style=plastic) | ![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/io.github.springwolf/springwolf-common-model-converters?label=springwolf-common-model-converters&server=https%3A%2F%2Fs01.oss.sonatype.org&style=plastic) | +| [Generic Binding](https://github.com/springwolf/springwolf-core/tree/master/springwolf-add-ons/springwolf-generic-binding) | | ![Maven Central](https://img.shields.io/maven-central/v/io.github.springwolf/springwolf-generic-binding?color=green&label=springwolf-generic-binding&style=plastic) | ![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/io.github.springwolf/springwolf-generic-binding?label=springwolf-generic-binding&server=https%3A%2F%2Fs01.oss.sonatype.org&style=plastic) | ### Development diff --git a/build.gradle b/build.gradle index 99746e2f8..56dabd845 100644 --- a/build.gradle +++ b/build.gradle @@ -71,7 +71,8 @@ allprojects { project.name == 'springwolf-sns' || project.name == 'springwolf-sqs' || project.name == 'springwolf-ui' || - project.name == 'springwolf-common-model-converters') + project.name == 'springwolf-common-model-converters' || + project.name == 'springwolf-generic-binding') tasks.withType(PublishToMavenRepository).configureEach { it.enabled = publishingEnabled } tasks.withType(PublishToMavenLocal).configureEach { it.enabled = publishingEnabled } publishing { diff --git a/settings.gradle b/settings.gradle index 21effccd9..88d272072 100644 --- a/settings.gradle +++ b/settings.gradle @@ -13,7 +13,8 @@ include( 'springwolf-examples:springwolf-sns-example', 'springwolf-examples:springwolf-sqs-example', 'springwolf-ui', - 'springwolf-add-ons:springwolf-common-model-converters' + 'springwolf-add-ons:springwolf-common-model-converters', + 'springwolf-add-ons:springwolf-generic-binding' ) project(':springwolf-plugins:springwolf-amqp-plugin').name = 'springwolf-amqp' diff --git a/springwolf-add-ons/springwolf-common-model-converters/README.md b/springwolf-add-ons/springwolf-common-model-converters/README.md index 1be4b63c3..39c879c0b 100644 --- a/springwolf-add-ons/springwolf-common-model-converters/README.md +++ b/springwolf-add-ons/springwolf-common-model-converters/README.md @@ -22,6 +22,6 @@ Add the following dependency: ```groovy dependencies { - implementation 'io.github.springwolf:springwolf-common-model-converters:0.1.1' + implementation 'io.github.springwolf:springwolf-common-model-converters:' } ``` diff --git a/springwolf-add-ons/springwolf-common-model-converters/src/main/java/.gitkeep b/springwolf-add-ons/springwolf-common-model-converters/src/main/java/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/common_converters/configuration/CommonModelConvertersAutoConfiguration.java b/springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/addons/common_model_converters/configuration/CommonModelConvertersAutoConfiguration.java similarity index 70% rename from springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/common_converters/configuration/CommonModelConvertersAutoConfiguration.java rename to springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/addons/common_model_converters/configuration/CommonModelConvertersAutoConfiguration.java index 1cc2b5d32..0145b7102 100644 --- a/springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/common_converters/configuration/CommonModelConvertersAutoConfiguration.java +++ b/springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/addons/common_model_converters/configuration/CommonModelConvertersAutoConfiguration.java @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.stavshamir.springwolf.common_converters.configuration; +package io.github.stavshamir.springwolf.addons.common_model_converters.configuration; -import io.github.stavshamir.springwolf.common_converters.converters.monetaryamount.MonetaryAmountConverter; +import io.github.stavshamir.springwolf.addons.common_model_converters.converters.monetaryamount.MonetaryAmountConverter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/common_converters/converters/monetaryamount/MonetaryAmount.java b/springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/addons/common_model_converters/converters/monetaryamount/MonetaryAmount.java similarity index 79% rename from springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/common_converters/converters/monetaryamount/MonetaryAmount.java rename to springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/addons/common_model_converters/converters/monetaryamount/MonetaryAmount.java index c6c516d45..ea6d52de3 100644 --- a/springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/common_converters/converters/monetaryamount/MonetaryAmount.java +++ b/springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/addons/common_model_converters/converters/monetaryamount/MonetaryAmount.java @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.stavshamir.springwolf.common_converters.converters.monetaryamount; +package io.github.stavshamir.springwolf.addons.common_model_converters.converters.monetaryamount; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/common_converters/converters/monetaryamount/MonetaryAmountConverter.java b/springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/addons/common_model_converters/converters/monetaryamount/MonetaryAmountConverter.java similarity index 90% rename from springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/common_converters/converters/monetaryamount/MonetaryAmountConverter.java rename to springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/addons/common_model_converters/converters/monetaryamount/MonetaryAmountConverter.java index c8f7a130e..d10d2203c 100644 --- a/springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/common_converters/converters/monetaryamount/MonetaryAmountConverter.java +++ b/springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/addons/common_model_converters/converters/monetaryamount/MonetaryAmountConverter.java @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.stavshamir.springwolf.common_converters.converters.monetaryamount; +package io.github.stavshamir.springwolf.addons.common_model_converters.converters.monetaryamount; import com.fasterxml.jackson.databind.JavaType; import io.swagger.v3.core.converter.AnnotatedType; diff --git a/springwolf-add-ons/springwolf-common-model-converters/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/springwolf-add-ons/springwolf-common-model-converters/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index f2839d7e3..82cd271e3 100644 --- a/springwolf-add-ons/springwolf-common-model-converters/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/springwolf-add-ons/springwolf-common-model-converters/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1 +1 @@ -io.github.stavshamir.springwolf.common_converters.configuration.CommonModelConvertersAutoConfiguration +io.github.stavshamir.springwolf.addons.common_model_converters.configuration.CommonModelConvertersAutoConfiguration diff --git a/springwolf-add-ons/springwolf-common-model-converters/src/test/java/.gitkeep b/springwolf-add-ons/springwolf-common-model-converters/src/test/java/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/springwolf-add-ons/springwolf-common-model-converters/src/test/java/io/github/stavshamir/springwolf/common_converters/converters/MonetaryAmountConverterTest.java b/springwolf-add-ons/springwolf-common-model-converters/src/test/java/io/github/stavshamir/springwolf/addons/common_model_converters/converters/MonetaryAmountConverterTest.java similarity index 86% rename from springwolf-add-ons/springwolf-common-model-converters/src/test/java/io/github/stavshamir/springwolf/common_converters/converters/MonetaryAmountConverterTest.java rename to springwolf-add-ons/springwolf-common-model-converters/src/test/java/io/github/stavshamir/springwolf/addons/common_model_converters/converters/MonetaryAmountConverterTest.java index 1e0b2de7e..dc5d43602 100644 --- a/springwolf-add-ons/springwolf-common-model-converters/src/test/java/io/github/stavshamir/springwolf/common_converters/converters/MonetaryAmountConverterTest.java +++ b/springwolf-add-ons/springwolf-common-model-converters/src/test/java/io/github/stavshamir/springwolf/addons/common_model_converters/converters/MonetaryAmountConverterTest.java @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.stavshamir.springwolf.common_converters.converters; +package io.github.stavshamir.springwolf.addons.common_model_converters.converters; -import io.github.stavshamir.springwolf.common_converters.converters.monetaryamount.MonetaryAmountConverter; +import io.github.stavshamir.springwolf.addons.common_model_converters.converters.monetaryamount.MonetaryAmountConverter; import io.swagger.v3.core.converter.AnnotatedType; import io.swagger.v3.core.converter.ModelConverters; import io.swagger.v3.oas.models.media.Schema; diff --git a/springwolf-add-ons/springwolf-generic-binding/README.md b/springwolf-add-ons/springwolf-generic-binding/README.md new file mode 100644 index 000000000..c2d935e0b --- /dev/null +++ b/springwolf-add-ons/springwolf-generic-binding/README.md @@ -0,0 +1,48 @@ +# Springwolf Generic Binding Add-on + +### Table Of Contents + +- [About](#about) +- [Usage](#usage) + - [Dependencies](#dependencies) + - [Code](#code) + +### About + +This module allows to document any binding in a generic way. + +It is intended to document fields that are not yet support by Springwolf and/or AsyncApi. +It can also be used to document vendor-specific protocols or properties. + +There exists no validation on key or value names. + +### Usage + +Add the following dependency: + +#### Dependencies + +```groovy +dependencies { + implementation 'io.github.springwolf:springwolf-generic-binding:' +} +``` + +#### Code + +```java +class TestClass { + @AsyncPublisher( + // ... + ) + @AsyncGenericOperationBinding( + type = "custom-binding", + fields = { + "internal-field=customValue", + "nested.key=nestedValue" + }) + public void sendMessage(AnotherPayloadDto msg) { + // ... + } +} +``` diff --git a/springwolf-add-ons/springwolf-generic-binding/build.gradle b/springwolf-add-ons/springwolf-generic-binding/build.gradle new file mode 100644 index 000000000..b403008f4 --- /dev/null +++ b/springwolf-add-ons/springwolf-generic-binding/build.gradle @@ -0,0 +1,51 @@ +plugins { + id 'java-library' + + id 'org.springframework.boot' + id 'io.spring.dependency-management' + id 'ca.cutterslade.analyze' +} + +dependencies { + api project(":springwolf-core") + + implementation "com.asyncapi:asyncapi-core:${asyncapiCoreVersion}" + implementation "org.slf4j:slf4j-api:${slf4jApiVersion}" + + implementation "org.springframework:spring-context" + implementation "org.springframework:spring-core" + + annotationProcessor "org.projectlombok:lombok:${lombokVersion}" + + testImplementation "org.assertj:assertj-core:${assertjCoreVersion}" + testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" + testRuntimeOnly "org.junit.jupiter:junit-jupiter:${junitJupiterVersion}" +} + +jar { + enabled = true + archiveClassifier = '' +} +bootJar.enabled = false + +java { + withJavadocJar() + withSourcesJar() +} + +test { + dependsOn spotlessApply // Automatically fix code formatting if possible + + useJUnitPlatform() +} + +publishing { + publications { + mavenJava(MavenPublication) { + pom { + name = 'springwolf-generic-binding' + description = 'Document any AsyncApi binding in Springwolf using a generic way' + } + } + } +} diff --git a/springwolf-add-ons/springwolf-generic-binding/src/main/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/AsyncGenericOperationBinding.java b/springwolf-add-ons/springwolf-generic-binding/src/main/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/AsyncGenericOperationBinding.java new file mode 100644 index 000000000..2dbd0dc8d --- /dev/null +++ b/springwolf-add-ons/springwolf-generic-binding/src/main/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/AsyncGenericOperationBinding.java @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: Apache-2.0 +package io.github.stavshamir.springwolf.addons.generic_binding.annotation; + +import io.github.stavshamir.springwolf.asyncapi.scanners.channels.annotation.AsyncOperationBinding; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Springwolf cannot support all available protocol bindings that exist. + * To allow users to manually define them, {@link AsyncGenericOperationBinding} can be used. + *

+ * Use the {@link AsyncGenericOperationBinding#fields()} to define the attributes + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(value = {ElementType.METHOD}) +@AsyncOperationBinding +public @interface AsyncGenericOperationBinding { + /** + * The name of the binding + */ + String type(); + + /** + * All binding fields + */ + String[] fields() default {}; +} diff --git a/springwolf-add-ons/springwolf-generic-binding/src/main/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/configuration/SpringwolfGenericBindingConfiguration.java b/springwolf-add-ons/springwolf-generic-binding/src/main/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/configuration/SpringwolfGenericBindingConfiguration.java new file mode 100644 index 000000000..43bf060a0 --- /dev/null +++ b/springwolf-add-ons/springwolf-generic-binding/src/main/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/configuration/SpringwolfGenericBindingConfiguration.java @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: Apache-2.0 +package io.github.stavshamir.springwolf.addons.generic_binding.annotation.configuration; + +import io.github.stavshamir.springwolf.addons.generic_binding.annotation.processor.AsyncGenericOperationBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.BindingProcessorPriority; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; + +@Configuration +public class SpringwolfGenericBindingConfiguration { + + @Bean + @Order(value = BindingProcessorPriority.GENERIC_BINDING) + public AsyncGenericOperationBindingProcessor asyncGenericOperationBindingProcessor() { + return new AsyncGenericOperationBindingProcessor(); + } +} diff --git a/springwolf-add-ons/springwolf-generic-binding/src/main/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/processor/AsyncGenericOperationBindingProcessor.java b/springwolf-add-ons/springwolf-generic-binding/src/main/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/processor/AsyncGenericOperationBindingProcessor.java new file mode 100644 index 000000000..14314f755 --- /dev/null +++ b/springwolf-add-ons/springwolf-generic-binding/src/main/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/processor/AsyncGenericOperationBindingProcessor.java @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: Apache-2.0 +package io.github.stavshamir.springwolf.addons.generic_binding.annotation.processor; + +import com.asyncapi.v2.binding.operation.OperationBinding; +import io.github.stavshamir.springwolf.addons.generic_binding.annotation.AsyncGenericOperationBinding; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.ProcessedOperationBinding; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor.AbstractOperationBindingProcessor; + +import java.util.HashMap; +import java.util.Map; + +public class AsyncGenericOperationBindingProcessor + extends AbstractOperationBindingProcessor { + + @Override + protected ProcessedOperationBinding mapToOperationBinding(AsyncGenericOperationBinding bindingAnnotation) { + Map bindingData = PropertiesUtil.toMap(bindingAnnotation.fields()); + + return new ProcessedOperationBinding( + bindingAnnotation.type(), new DefaultAsyncGenerialOperationBinding(bindingData)); + } + + public static class DefaultAsyncGenerialOperationBinding extends OperationBinding { + public DefaultAsyncGenerialOperationBinding(Map properties) { + this.extensionFields = new HashMap<>(properties); + } + } +} diff --git a/springwolf-add-ons/springwolf-generic-binding/src/main/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/processor/PropertiesUtil.java b/springwolf-add-ons/springwolf-generic-binding/src/main/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/processor/PropertiesUtil.java new file mode 100644 index 000000000..35d023bcd --- /dev/null +++ b/springwolf-add-ons/springwolf-generic-binding/src/main/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/processor/PropertiesUtil.java @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: Apache-2.0 +package io.github.stavshamir.springwolf.addons.generic_binding.annotation.processor; + +import lombok.extern.slf4j.Slf4j; + +import java.io.IOException; +import java.io.StringReader; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; +import java.util.Properties; + +@Slf4j +public class PropertiesUtil { + + public static Map toMap(String[] propertyStrings) { + return convertPropertiesToNestedMap(buildPropertiesFrom((propertyStrings))); + } + + private static Properties buildPropertiesFrom(String[] propertyStrings) { + Properties properties = new Properties(); + for (String bindingProperty : propertyStrings) { + try { + properties.load(new StringReader(bindingProperty)); + } catch (IOException e) { + log.warn("Unable to parse property {}", bindingProperty, e); + } + } + return properties; + } + + @SuppressWarnings("unchecked") + private static Map convertPropertiesToNestedMap(Properties properties) { + Map bindingData = new HashMap<>(); + for (String propertyName : properties.stringPropertyNames()) { + LinkedList path = new LinkedList<>(Arrays.asList(propertyName.split("\\."))); + + Map mapNode = bindingData; + while (path.size() > 1) { + String pathElement = path.get(0); + if (!mapNode.containsKey(pathElement)) { + mapNode.put(pathElement, new HashMap<>()); + } + + mapNode = (Map) mapNode.get(pathElement); + + path.pop(); + } + + mapNode.put(path.get(0), properties.get(propertyName)); + } + return bindingData; + } +} diff --git a/springwolf-add-ons/springwolf-generic-binding/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/springwolf-add-ons/springwolf-generic-binding/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 000000000..c076e2651 --- /dev/null +++ b/springwolf-add-ons/springwolf-generic-binding/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +io.github.stavshamir.springwolf.addons.generic_binding.annotation.processor.AsyncGenericOperationBindingProcessor diff --git a/springwolf-add-ons/springwolf-generic-binding/src/test/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/processor/AsyncGenericOperationBindingProcessorTest.java b/springwolf-add-ons/springwolf-generic-binding/src/test/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/processor/AsyncGenericOperationBindingProcessorTest.java new file mode 100644 index 000000000..40b50c3f1 --- /dev/null +++ b/springwolf-add-ons/springwolf-generic-binding/src/test/java/io/github/stavshamir/springwolf/addons/generic_binding/annotation/processor/AsyncGenericOperationBindingProcessorTest.java @@ -0,0 +1,138 @@ +// SPDX-License-Identifier: Apache-2.0 +package io.github.stavshamir.springwolf.addons.generic_binding.annotation.processor; + +import io.github.stavshamir.springwolf.addons.generic_binding.annotation.AsyncGenericOperationBinding; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.ProcessedOperationBinding; +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import static org.assertj.core.api.Assertions.assertThat; + +class AsyncGenericOperationBindingProcessorTest { + + private final AsyncGenericOperationBindingProcessor processor = new AsyncGenericOperationBindingProcessor(); + + @Test + void testClassWithoutAnnotation() { + // when + List result = getProcessedOperationBindings(ClassWithoutAnnotation.class); + + // then + assertThat(result).hasSize(0); + } + + @Test + void testClassWithAnnotationHasABinding() { + // when + List result = getProcessedOperationBindings(ClassWithAnnotation.class); + + // then + assertThat(result).hasSize(1); + ProcessedOperationBinding processedOperationBinding = result.get(0); + assertThat(processedOperationBinding.getType()).isEqualTo("test-binding"); + AsyncGenericOperationBindingProcessor.DefaultAsyncGenerialOperationBinding binding = + (AsyncGenericOperationBindingProcessor.DefaultAsyncGenerialOperationBinding) + processedOperationBinding.getBinding(); + assertThat(binding.getExtensionFields()).isEqualTo(Map.of("binding", Map.of("field", "1"), "field", "true")); + } + + private List getProcessedOperationBindings(Class testClass) { + List result = Arrays.stream(testClass.getDeclaredMethods()) + .map((m) -> m.getAnnotationsByType(AsyncGenericOperationBinding.class)) + .flatMap(Arrays::stream) + .map(processor::mapToOperationBinding) + .toList(); + return result; + } + + private static class ClassWithoutAnnotation { + private void methodWithoutAnnotation() {} + } + + private static class ClassWithAnnotation { + @AsyncGenericOperationBinding( + type = "test-binding", + fields = {"binding.field=1", "field=true"}) + private void methodWithAnnotation() {} + + private void methodWithoutAnnotation() {} + } + + static class PropertiesUtilTest { + + @Test + void emptyTest() { + // given + String[] strings = {}; + + // when + Map result = PropertiesUtil.toMap(strings); + + // then + assertThat(result).isEmpty(); + } + + @Test + void onePropertyTest() { + // given + String[] strings = {"key=value"}; + + // when + Map result = PropertiesUtil.toMap(strings); + + // then + assertThat(result).isEqualTo(Map.of("key", "value")); + } + + @Test + void twoPropertiesTest() { + // given + String[] strings = {"key1=value1", "key2=value2"}; + + // when + Map result = PropertiesUtil.toMap(strings); + + // then + assertThat(result).isEqualTo(Map.of("key1", "value1", "key2", "value2")); + } + + @Test + void nestedPropertyTest() { + // given + String[] strings = {"nested.key=value"}; + + // when + Map result = PropertiesUtil.toMap(strings); + + // then + assertThat(result).isEqualTo(Map.of("nested", Map.of("key", "value"))); + } + + @Test + void deeplyNestedPropertyTest() { + // given + String[] strings = {"very.deeply.nested.key=value"}; + + // when + Map result = PropertiesUtil.toMap(strings); + + // then + assertThat(result).isEqualTo(Map.of("very", Map.of("deeply", Map.of("nested", Map.of("key", "value"))))); + } + + @Test + void yamlSyntaxDoesWorkAsWell() { + // given + String[] strings = {"key: value"}; + + // when + Map result = PropertiesUtil.toMap(strings); + + // then + assertThat(result).isEqualTo(Map.of("key", "value")); + } + } +} 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 da0483786..cd7637c8d 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,13 +3,13 @@ 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.bindings.MessageBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.OperationBindingProcessor; 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; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AsyncPublisherAnnotationScanner; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.MessageBindingProcessor; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.OperationBindingProcessor; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ComponentClassScanner; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ConfigurationClassScanner; import io.github.stavshamir.springwolf.configuration.AsyncApiDocketService; diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/BindingProcessorPriority.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/BindingProcessorPriority.java new file mode 100644 index 000000000..6c6057e76 --- /dev/null +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/BindingProcessorPriority.java @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: Apache-2.0 +package io.github.stavshamir.springwolf.asyncapi.scanners.bindings; + +import io.github.stavshamir.springwolf.configuration.AsyncApiDocket; + +/** + * Order of binding processors + */ +public class BindingProcessorPriority { + /** + * Manual defined binding processors have the highest priority + *

+ * Example: Definition via {@link AsyncApiDocket} + */ + public static final int MANUAL_DEFINED = 1; + + /** + * Definition via generic annotation + *

+ * to extend and overwrite the protocol binding - which might not support all features + *

+ * Example: AsyncGenericOperationBinding + */ + public static final int GENERIC_BINDING = 2; + + /** + * Protocol specific bindings, which try to auto-detect all fields + *

+ * Examples: Plugins like KafkaOperationBindingProcessor, etc + */ + public static final int PROTOCOL_BINDING = 3; +} diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/MessageBindingProcessor.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/MessageBindingProcessor.java similarity index 72% rename from springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/MessageBindingProcessor.java rename to springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/MessageBindingProcessor.java index 314680182..4df365895 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/MessageBindingProcessor.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/MessageBindingProcessor.java @@ -1,7 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation; +package io.github.stavshamir.springwolf.asyncapi.scanners.bindings; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.ProcessedMessageBinding; +import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AsyncListener; +import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AsyncPublisher; import java.lang.reflect.Method; import java.util.Optional; diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/OperationBindingProcessor.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/OperationBindingProcessor.java similarity index 72% rename from springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/OperationBindingProcessor.java rename to springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/OperationBindingProcessor.java index badcb1f3f..a781ed275 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/OperationBindingProcessor.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/OperationBindingProcessor.java @@ -1,7 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation; +package io.github.stavshamir.springwolf.asyncapi.scanners.bindings; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.ProcessedOperationBinding; +import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AsyncListener; +import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AsyncPublisher; import java.lang.reflect.Method; import java.util.Optional; diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ProcessedMessageBinding.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/ProcessedMessageBinding.java similarity index 74% rename from springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ProcessedMessageBinding.java rename to springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/ProcessedMessageBinding.java index 96640f0fc..4634e550d 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ProcessedMessageBinding.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/ProcessedMessageBinding.java @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata; +package io.github.stavshamir.springwolf.asyncapi.scanners.bindings; import com.asyncapi.v2.binding.message.MessageBinding; import lombok.Data; diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ProcessedOperationBinding.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/ProcessedOperationBinding.java similarity index 74% rename from springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ProcessedOperationBinding.java rename to springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/ProcessedOperationBinding.java index cd118aeef..3ba4e9557 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/ProcessedOperationBinding.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/ProcessedOperationBinding.java @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata; +package io.github.stavshamir.springwolf.asyncapi.scanners.bindings; import com.asyncapi.v2.binding.operation.OperationBinding; import lombok.Data; diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/AbstractOperationBindingProcessor.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/AbstractOperationBindingProcessor.java similarity index 53% rename from springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/AbstractOperationBindingProcessor.java rename to springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/AbstractOperationBindingProcessor.java index e3cba487a..c4e3546e7 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/AbstractOperationBindingProcessor.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/AbstractOperationBindingProcessor.java @@ -1,20 +1,27 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.stavshamir.springwolf.asyncapi.scanners.channels; +package io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.OperationBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.ProcessedOperationBinding; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.annotation.AsyncOperationBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.ProcessedOperationBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.OperationBindingProcessor; +import lombok.extern.slf4j.Slf4j; import org.springframework.context.EmbeddedValueResolverAware; import org.springframework.util.StringUtils; import org.springframework.util.StringValueResolver; +import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.util.Arrays; import java.util.Optional; +import java.util.stream.Stream; +@Slf4j public abstract class AbstractOperationBindingProcessor implements OperationBindingProcessor, EmbeddedValueResolverAware { + + private final Class specificAnnotationClazz = + (Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; private StringValueResolver resolver; @Override @@ -24,17 +31,28 @@ public void setEmbeddedValueResolver(StringValueResolver resolver) { @Override public Optional process(Method method) { - final Class clazz = getGenericAnnotationClass(); - return Arrays.stream(method.getAnnotations()) .filter(annotation -> annotation.annotationType().isAnnotationPresent(AsyncOperationBinding.class)) - .map(clazz::cast) + .flatMap(this::tryCast) .findAny() .map(this::mapToOperationBinding); } - private Class getGenericAnnotationClass() { - return (Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; + /** + * Attempt to cast the annotation to the specific annotation + * + * Casting might fail, when multiple, different binding annotations are used, + * which results in an (expected) exception. + * + * If there is an option to previously test casting without casting, then lets change the code here. + */ + private Stream tryCast(Annotation obj) { + try { + return Stream.of(specificAnnotationClazz.cast(obj)); + } catch (ClassCastException ex) { + log.trace("Method has multiple bindings defined.", ex); + } + return Stream.empty(); } protected abstract ProcessedOperationBinding mapToOperationBinding(A bindingAnnotation); diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncAnnotationScannerUtil.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncAnnotationScannerUtil.java index 0b6a90255..86ecae58a 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncAnnotationScannerUtil.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncAnnotationScannerUtil.java @@ -3,8 +3,10 @@ import com.asyncapi.v2.binding.message.MessageBinding; import com.asyncapi.v2.binding.operation.OperationBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.ProcessedMessageBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.ProcessedOperationBinding; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.MessageBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.OperationBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.ProcessedMessageBinding; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.ProcessedOperationBinding; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.header.AsyncHeaderSchema; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.header.AsyncHeaders; @@ -69,7 +71,8 @@ public static Map processOperationBindingFromAnnotatio .map(operationBindingProcessor -> operationBindingProcessor.process(method)) .filter(Optional::isPresent) .map(Optional::get) - .collect(Collectors.toMap(ProcessedOperationBinding::getType, ProcessedOperationBinding::getBinding)); + .collect(Collectors.toMap( + ProcessedOperationBinding::getType, ProcessedOperationBinding::getBinding, (e1, e2) -> e1)); } public static Map processMessageBindingFromAnnotation( @@ -78,7 +81,8 @@ public static Map processMessageBindingFromAnnotation( .map(messageBindingProcessor -> messageBindingProcessor.process(method)) .filter(Optional::isPresent) .map(Optional::get) - .collect(Collectors.toMap(ProcessedMessageBinding::getType, ProcessedMessageBinding::getBinding)); + .collect(Collectors.toMap( + ProcessedMessageBinding::getType, ProcessedMessageBinding::getBinding, (e1, e2) -> e2)); } public static Message processMessageFromAnnotation(Method method) { 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 1b3a5ce51..065730ea6 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,6 +3,8 @@ import com.asyncapi.v2.binding.message.MessageBinding; import com.asyncapi.v2.binding.operation.OperationBinding; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.MessageBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.OperationBindingProcessor; 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; 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 a6a269ad6..142e3119d 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,6 +3,8 @@ import com.asyncapi.v2.binding.message.MessageBinding; import com.asyncapi.v2.binding.operation.OperationBinding; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.MessageBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.OperationBindingProcessor; 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; diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/TestAbstractOperationBindingProcessor.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/TestAbstractOperationBindingProcessor.java similarity index 54% rename from springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/TestAbstractOperationBindingProcessor.java rename to springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/TestAbstractOperationBindingProcessor.java index 206e81de5..30d13dd5a 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/TestAbstractOperationBindingProcessor.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/TestAbstractOperationBindingProcessor.java @@ -1,20 +1,23 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation; +package io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor; import com.asyncapi.v2.binding.operation.OperationBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.AbstractOperationBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.BindingProcessorPriority; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.ProcessedOperationBinding; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.annotation.AsyncOperationBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.ProcessedOperationBinding; +import org.springframework.core.annotation.Order; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import java.util.HashMap; +@Order(value = BindingProcessorPriority.MANUAL_DEFINED) public class TestAbstractOperationBindingProcessor extends AbstractOperationBindingProcessor { public static final String TYPE = "testType"; - public static final OperationBinding BINDING = new OperationBinding(); + public static final OperationBinding BINDING = new AbstractOperationBindingBinding(); @Override protected ProcessedOperationBinding mapToOperationBinding(TestOperationBinding bindingAnnotation) { @@ -25,7 +28,14 @@ protected ProcessedOperationBinding mapToOperationBinding(TestOperationBinding b @Target(value = {ElementType.METHOD}) @AsyncOperationBinding public @interface TestOperationBinding { - TestMessageBindingProcessor.TestMessageBinding messageBinding() default + TestMessageBindingProcessor.TestMessageBinding operationBinding() default @TestMessageBindingProcessor.TestMessageBinding(); } + + public static class AbstractOperationBindingBinding extends OperationBinding { + public AbstractOperationBindingBinding() { + this.extensionFields = new HashMap<>(); + this.extensionFields.put("type", this.getClass().getName()); + } + } } diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/TestMessageBindingProcessor.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/TestMessageBindingProcessor.java similarity index 74% rename from springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/TestMessageBindingProcessor.java rename to springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/TestMessageBindingProcessor.java index 63dad41fa..ff93beff6 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/TestMessageBindingProcessor.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/TestMessageBindingProcessor.java @@ -1,8 +1,11 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation; +package io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor; import com.asyncapi.v2.binding.message.MessageBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.ProcessedMessageBinding; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.BindingProcessorPriority; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.MessageBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.ProcessedMessageBinding; +import org.springframework.core.annotation.Order; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -12,6 +15,7 @@ import java.util.Arrays; import java.util.Optional; +@Order(value = BindingProcessorPriority.MANUAL_DEFINED) public class TestMessageBindingProcessor implements MessageBindingProcessor { public static final String TYPE = "testType"; diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/TestOperationBindingProcessor.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/TestOperationBindingProcessor.java similarity index 50% rename from springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/TestOperationBindingProcessor.java rename to springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/TestOperationBindingProcessor.java index e3a486993..a1c5b2dd2 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/TestOperationBindingProcessor.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/TestOperationBindingProcessor.java @@ -1,19 +1,24 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation; +package io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor; import com.asyncapi.v2.binding.operation.OperationBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.ProcessedOperationBinding; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.BindingProcessorPriority; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.OperationBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.ProcessedOperationBinding; +import org.springframework.core.annotation.Order; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.Method; +import java.util.HashMap; import java.util.Optional; +@Order(value = BindingProcessorPriority.MANUAL_DEFINED) public class TestOperationBindingProcessor implements OperationBindingProcessor { public static final String TYPE = "testType"; - public static final OperationBinding BINDING = new OperationBinding(); + public static final OperationBinding BINDING = new TestOperationBindingBinding(); @Override public Optional process(Method method) { @@ -26,7 +31,14 @@ public Optional process(Method method) { @Retention(RetentionPolicy.RUNTIME) @Target(value = {ElementType.METHOD}) public @interface TestOperationBinding { - TestMessageBindingProcessor.TestMessageBinding messageBinding() default + TestMessageBindingProcessor.TestMessageBinding operationBinding() default @TestMessageBindingProcessor.TestMessageBinding(); } + + public static class TestOperationBindingBinding extends OperationBinding { + public TestOperationBindingBinding() { + this.extensionFields = new HashMap<>(); + this.extensionFields.put("type", this.getClass().getName()); + } + } } diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncAnnotationScannerUtilTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncAnnotationScannerUtilTest.java index 7c5d3b461..1b56e92e3 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncAnnotationScannerUtilTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncAnnotationScannerUtilTest.java @@ -3,6 +3,9 @@ import com.asyncapi.v2.binding.message.MessageBinding; import com.asyncapi.v2.binding.operation.OperationBinding; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor.TestAbstractOperationBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor.TestMessageBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor.TestOperationBindingProcessor; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.header.AsyncHeaders; import org.assertj.core.util.Maps; @@ -13,9 +16,11 @@ import java.lang.reflect.Method; import java.util.Collections; +import java.util.List; import java.util.Map; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; @@ -46,7 +51,7 @@ void getAsyncHeaders(Class classWithOperationBindingProcessor) throws NoSuchM } @Test - void processBindingFromAnnotation() throws NoSuchMethodException { + void processOperationBindingFromAnnotation() throws NoSuchMethodException { // given Method m = ClassWithOperationBindingProcessor.class.getDeclaredMethod("methodWithAnnotation", String.class); @@ -59,6 +64,25 @@ void processBindingFromAnnotation() throws NoSuchMethodException { Maps.newHashMap(TestOperationBindingProcessor.TYPE, TestOperationBindingProcessor.BINDING), bindings); } + @Test + void processMultipleOperationBindingFromAnnotation() throws NoSuchMethodException { + // given + Method m = ClassWithMultipleOperationBindingProcessors.class.getDeclaredMethod( + "methodWithAnnotation", String.class); + + // when + Map bindings = AsyncAnnotationScannerUtil.processOperationBindingFromAnnotation( + m, List.of(new TestOperationBindingProcessor(), new TestAbstractOperationBindingProcessor())); + + // then + assertEquals( + Maps.newHashMap(TestOperationBindingProcessor.TYPE, TestOperationBindingProcessor.BINDING), bindings); + assertNotEquals( + Maps.newHashMap( + TestAbstractOperationBindingProcessor.TYPE, TestAbstractOperationBindingProcessor.BINDING), + bindings); + } + @Test void processMessageBindingFromAnnotation() throws NoSuchMethodException { // given @@ -72,6 +96,20 @@ void processMessageBindingFromAnnotation() throws NoSuchMethodException { assertEquals(Maps.newHashMap(TestMessageBindingProcessor.TYPE, TestMessageBindingProcessor.BINDING), bindings); } + @Test + void processMultipleMessageBindingFromAnnotation() throws NoSuchMethodException { + // given + Method m = ClassWithMultipleOperationBindingProcessors.class.getDeclaredMethod( + "methodWithAnnotation", String.class); + + // when + Map bindings = AsyncAnnotationScannerUtil.processMessageBindingFromAnnotation( + m, List.of(new TestMessageBindingProcessor())); + + // then + assertEquals(Maps.newHashMap(TestMessageBindingProcessor.TYPE, TestMessageBindingProcessor.BINDING), bindings); + } + @ParameterizedTest @ValueSource(classes = {ClassWithOperationBindingProcessor.class, ClassWithAbstractOperationBindingProcessor.class}) void processMessageFromAnnotationWithoutAsyncMessage(Class classWithOperationBindingProcessor) @@ -194,4 +232,15 @@ private void methodWithAnnotation(String payload) {} @TestAbstractOperationBindingProcessor.TestOperationBinding() private void methodWithAsyncMessageAnnotation(String payload) {} } + + private static class ClassWithMultipleOperationBindingProcessors { + @AsyncListener( + operation = + @AsyncOperation( + channelName = "${test.property.test-channel}", + description = "${test.property.description}")) + @TestOperationBindingProcessor.TestOperationBinding() + @TestAbstractOperationBindingProcessor.TestOperationBinding() + private void methodWithAnnotation(String payload) {} + } } diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncListenerAnnotationScannerIntegrationTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncListenerAnnotationScannerIntegrationTest.java index b8b0cc2f1..31e777733 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncListenerAnnotationScannerIntegrationTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncListenerAnnotationScannerIntegrationTest.java @@ -3,6 +3,7 @@ import com.asyncapi.v2._6_0.model.channel.ChannelItem; import com.asyncapi.v2._6_0.model.channel.operation.Operation; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor.TestOperationBindingProcessor; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ComponentClassScanner; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.PayloadReference; diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncPublisherAnnotationScannerIntegrationTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncPublisherAnnotationScannerIntegrationTest.java index 66d0d8df4..5b6f0b96a 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncPublisherAnnotationScannerIntegrationTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AsyncPublisherAnnotationScannerIntegrationTest.java @@ -3,6 +3,7 @@ import com.asyncapi.v2._6_0.model.channel.ChannelItem; import com.asyncapi.v2._6_0.model.channel.operation.Operation; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor.TestOperationBindingProcessor; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ComponentClassScanner; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.PayloadReference; diff --git a/springwolf-examples/springwolf-sqs-example/build.gradle b/springwolf-examples/springwolf-sqs-example/build.gradle index 7a48cbc2d..7c04445ba 100644 --- a/springwolf-examples/springwolf-sqs-example/build.gradle +++ b/springwolf-examples/springwolf-sqs-example/build.gradle @@ -16,6 +16,7 @@ dependencyManagement { dependencies { implementation project(":springwolf-core") + implementation project(":springwolf-add-ons:springwolf-generic-binding") implementation project(":springwolf-plugins:springwolf-sqs") annotationProcessor project(":springwolf-plugins:springwolf-sqs") diff --git a/springwolf-examples/springwolf-sqs-example/src/main/java/io/github/stavshamir/springwolf/example/sqs/producers/AnotherProducer.java b/springwolf-examples/springwolf-sqs-example/src/main/java/io/github/stavshamir/springwolf/example/sqs/producers/AnotherProducer.java index fd22e1d6d..b810728e3 100644 --- a/springwolf-examples/springwolf-sqs-example/src/main/java/io/github/stavshamir/springwolf/example/sqs/producers/AnotherProducer.java +++ b/springwolf-examples/springwolf-sqs-example/src/main/java/io/github/stavshamir/springwolf/example/sqs/producers/AnotherProducer.java @@ -2,6 +2,7 @@ package io.github.stavshamir.springwolf.example.sqs.producers; import io.awspring.cloud.sqs.operations.SqsTemplate; +import io.github.stavshamir.springwolf.addons.generic_binding.annotation.AsyncGenericOperationBinding; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AsyncOperation; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AsyncPublisher; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.SqsAsyncOperationBinding; @@ -22,6 +23,9 @@ public class AnotherProducer { channelName = QUEUE, description = "Custom, optional description defined in the AsyncPublisher annotation")) @SqsAsyncOperationBinding + @AsyncGenericOperationBinding( + type = "sqs", + fields = {"internal-field=customValue", "nested.key=nestedValue"}) public void sendMessage(AnotherPayloadDto msg) { template.send(QUEUE, msg); } 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 286875f40..3c223d370 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,11 +1,12 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.stavshamir.springwolf.asyncapi.amqp; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.BindingProcessorPriority; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor.AmqpMessageBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor.AmqpOperationBindingProcessor; 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; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.AmqpOperationBindingProcessor; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ComponentClassScanner; import io.github.stavshamir.springwolf.schemas.SchemasService; import org.springframework.amqp.core.Binding; @@ -51,11 +52,13 @@ public MethodLevelRabbitListenerScanner methodLevelRabbitListenerScanner( } @Bean + @Order(value = BindingProcessorPriority.PROTOCOL_BINDING) public AmqpMessageBindingProcessor amqpMessageBindingProcessor() { return new AmqpMessageBindingProcessor(); } @Bean + @Order(value = BindingProcessorPriority.PROTOCOL_BINDING) public AmqpOperationBindingProcessor amqpOperationBindingProcessor() { return new AmqpOperationBindingProcessor(); } diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/AmqpMessageBindingProcessor.java b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/AmqpMessageBindingProcessor.java similarity index 84% rename from springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/AmqpMessageBindingProcessor.java rename to springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/AmqpMessageBindingProcessor.java index 978312ea2..9fb8bac40 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/AmqpMessageBindingProcessor.java +++ b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/AmqpMessageBindingProcessor.java @@ -1,9 +1,10 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata; +package io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor; import com.asyncapi.v2.binding.message.amqp.AMQPMessageBinding; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.MessageBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.ProcessedMessageBinding; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AmqpAsyncOperationBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.MessageBindingProcessor; import org.springframework.context.EmbeddedValueResolverAware; import org.springframework.util.StringValueResolver; diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/AmqpOperationBindingProcessor.java b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/AmqpOperationBindingProcessor.java similarity index 86% rename from springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/AmqpOperationBindingProcessor.java rename to springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/AmqpOperationBindingProcessor.java index 8fd2b2676..9aaf5b0e5 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/AmqpOperationBindingProcessor.java +++ b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/AmqpOperationBindingProcessor.java @@ -1,8 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata; +package io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor; import com.asyncapi.v2.binding.operation.amqp.AMQPOperationBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.AbstractOperationBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.ProcessedOperationBinding; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AmqpAsyncOperationBinding; import java.util.Arrays; diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/kafka/SpringwolfKafkaScannerConfiguration.java b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/kafka/SpringwolfKafkaScannerConfiguration.java index 39bcde6a7..e24293cb1 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/kafka/SpringwolfKafkaScannerConfiguration.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/kafka/SpringwolfKafkaScannerConfiguration.java @@ -1,11 +1,12 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.stavshamir.springwolf.asyncapi.kafka; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.BindingProcessorPriority; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor.KafkaMessageBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor.KafkaOperationBindingProcessor; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelPriority; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.annotation.ClassLevelKafkaListenerScanner; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.annotation.MethodLevelKafkaListenerScanner; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.KafkaMessageBindingProcessor; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.KafkaOperationBindingProcessor; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ComponentClassScanner; import io.github.stavshamir.springwolf.schemas.SchemasService; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -38,11 +39,13 @@ public MethodLevelKafkaListenerScanner methodLevelKafkaListenerScanner( } @Bean + @Order(value = BindingProcessorPriority.PROTOCOL_BINDING) public KafkaMessageBindingProcessor kafkaMessageBindingProcessor() { return new KafkaMessageBindingProcessor(); } @Bean + @Order(value = BindingProcessorPriority.PROTOCOL_BINDING) public KafkaOperationBindingProcessor kafkaOperationBindingProcessor() { return new KafkaOperationBindingProcessor(); } diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/KafkaMessageBindingProcessor.java b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/KafkaMessageBindingProcessor.java similarity index 91% rename from springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/KafkaMessageBindingProcessor.java rename to springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/KafkaMessageBindingProcessor.java index e30a25fcd..a19a64c96 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/KafkaMessageBindingProcessor.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/KafkaMessageBindingProcessor.java @@ -1,10 +1,11 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata; +package io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor; import com.asyncapi.v2.binding.message.kafka.KafkaMessageBinding; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.MessageBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.ProcessedMessageBinding; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.KafkaAsyncOperationBinding; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.KafkaAsyncOperationBinding.KafkaAsyncMessageBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.MessageBindingProcessor; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.StringSchema; import org.springframework.context.EmbeddedValueResolverAware; diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/KafkaOperationBindingProcessor.java b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/KafkaOperationBindingProcessor.java similarity index 89% rename from springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/KafkaOperationBindingProcessor.java rename to springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/KafkaOperationBindingProcessor.java index 6be7185a9..361901d0f 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/KafkaOperationBindingProcessor.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/KafkaOperationBindingProcessor.java @@ -1,9 +1,9 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata; +package io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor; import com.asyncapi.v2.binding.operation.kafka.KafkaOperationBinding; import com.asyncapi.v2.schema.Schema; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.AbstractOperationBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.ProcessedOperationBinding; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.annotation.KafkaListenerUtil; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.KafkaAsyncOperationBinding; import org.springframework.util.StringUtils; diff --git a/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/SnsMessageBindingProcessor.java b/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/SnsMessageBindingProcessor.java index 52099c563..9194c2a95 100644 --- a/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/SnsMessageBindingProcessor.java +++ b/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/SnsMessageBindingProcessor.java @@ -2,7 +2,8 @@ package io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata; import com.asyncapi.v2.binding.message.sns.SNSMessageBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.MessageBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.MessageBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.ProcessedMessageBinding; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.SnsAsyncOperationBinding; import org.springframework.context.EmbeddedValueResolverAware; import org.springframework.util.StringValueResolver; diff --git a/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/SnsOperationBindingProcessor.java b/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/SnsOperationBindingProcessor.java index b46eed5ca..d794787bf 100644 --- a/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/SnsOperationBindingProcessor.java +++ b/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/SnsOperationBindingProcessor.java @@ -2,7 +2,8 @@ package io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata; import com.asyncapi.v2.binding.operation.sqs.SQSOperationBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.AbstractOperationBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.ProcessedOperationBinding; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor.AbstractOperationBindingProcessor; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.SnsAsyncOperationBinding; public class SnsOperationBindingProcessor extends AbstractOperationBindingProcessor { diff --git a/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/sns/SpringwolfSnsScannerConfiguration.java b/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/sns/SpringwolfSnsScannerConfiguration.java index d911ec0df..f3000bfa1 100644 --- a/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/sns/SpringwolfSnsScannerConfiguration.java +++ b/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/sns/SpringwolfSnsScannerConfiguration.java @@ -1,10 +1,12 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.stavshamir.springwolf.asyncapi.sns; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.BindingProcessorPriority; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.SnsMessageBindingProcessor; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.SnsOperationBindingProcessor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; /** * spring configuration defining the scanner beans for the sns plugin @@ -13,11 +15,13 @@ public class SpringwolfSnsScannerConfiguration { @Bean + @Order(value = BindingProcessorPriority.PROTOCOL_BINDING) public SnsMessageBindingProcessor snsMessageBindingProcessor() { return new SnsMessageBindingProcessor(); } @Bean + @Order(value = BindingProcessorPriority.PROTOCOL_BINDING) public SnsOperationBindingProcessor snsOperationBindingProcessor() { return new SnsOperationBindingProcessor(); } diff --git a/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/SqsMessageBindingProcessor.java b/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/SqsMessageBindingProcessor.java similarity index 84% rename from springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/SqsMessageBindingProcessor.java rename to springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/SqsMessageBindingProcessor.java index 3dd0c257e..fd8acfae1 100644 --- a/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/SqsMessageBindingProcessor.java +++ b/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/SqsMessageBindingProcessor.java @@ -1,8 +1,9 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata; +package io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor; import com.asyncapi.v2.binding.message.amqp.AMQPMessageBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.MessageBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.MessageBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.ProcessedMessageBinding; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.SqsAsyncOperationBinding; import org.springframework.context.EmbeddedValueResolverAware; import org.springframework.util.StringValueResolver; diff --git a/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/SqsOperationBindingProcessor.java b/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/SqsOperationBindingProcessor.java similarity index 75% rename from springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/SqsOperationBindingProcessor.java rename to springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/SqsOperationBindingProcessor.java index 8997ece7a..d94a507bb 100644 --- a/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/SqsOperationBindingProcessor.java +++ b/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/bindings/processor/SqsOperationBindingProcessor.java @@ -1,8 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 -package io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata; +package io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor; import com.asyncapi.v2.binding.operation.sqs.SQSOperationBinding; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.AbstractOperationBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.ProcessedOperationBinding; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.SqsAsyncOperationBinding; public class SqsOperationBindingProcessor extends AbstractOperationBindingProcessor { diff --git a/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/sqs/SpringwolfSqsScannerConfiguration.java b/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/sqs/SpringwolfSqsScannerConfiguration.java index 06d437e19..8db292ca9 100644 --- a/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/sqs/SpringwolfSqsScannerConfiguration.java +++ b/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/sqs/SpringwolfSqsScannerConfiguration.java @@ -1,10 +1,11 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.stavshamir.springwolf.asyncapi.sqs; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.BindingProcessorPriority; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor.SqsMessageBindingProcessor; +import io.github.stavshamir.springwolf.asyncapi.scanners.bindings.processor.SqsOperationBindingProcessor; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelPriority; import io.github.stavshamir.springwolf.asyncapi.scanners.channels.annotation.MethodLevelSqsListenerScanner; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.SqsMessageBindingProcessor; -import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.SqsOperationBindingProcessor; import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ComponentClassScanner; import io.github.stavshamir.springwolf.schemas.SchemasService; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -29,11 +30,13 @@ public MethodLevelSqsListenerScanner methodLevelSqsListenerScanner( } @Bean + @Order(value = BindingProcessorPriority.PROTOCOL_BINDING) public SqsMessageBindingProcessor sqsMessageBindingProcessor() { return new SqsMessageBindingProcessor(); } @Bean + @Order(value = BindingProcessorPriority.PROTOCOL_BINDING) public SqsOperationBindingProcessor sqsOperationBindingProcessor() { return new SqsOperationBindingProcessor(); }