From e98866611a7580cd49100876bb5c33683ecfdba3 Mon Sep 17 00:00:00 2001 From: Timon Back Date: Sat, 27 Apr 2024 21:42:50 +0200 Subject: [PATCH 1/7] feat: add jms bindings artifact --- springwolf-bindings/springwolf-jms-binding/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/springwolf-bindings/springwolf-jms-binding/build.gradle b/springwolf-bindings/springwolf-jms-binding/build.gradle index d3ed9398d..c02af05a8 100644 --- a/springwolf-bindings/springwolf-jms-binding/build.gradle +++ b/springwolf-bindings/springwolf-jms-binding/build.gradle @@ -14,6 +14,8 @@ dependencies { implementation "org.springframework:spring-core" implementation "org.springframework.boot:spring-boot-autoconfigure" + implementation "org.apache.commons:commons-lang3:${commonsLang3Version}" + testImplementation "org.assertj:assertj-core:${assertjCoreVersion}" testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" From ef82112e97e45e6d0112722926ea313339dc486f Mon Sep 17 00:00:00 2001 From: Timon Back Date: Sat, 27 Apr 2024 21:51:11 +0200 Subject: [PATCH 2/7] feat: add amqp bindings artifact --- springwolf-bindings/springwolf-amqp-binding/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/springwolf-bindings/springwolf-amqp-binding/build.gradle b/springwolf-bindings/springwolf-amqp-binding/build.gradle index 4b92963bc..762299e1d 100644 --- a/springwolf-bindings/springwolf-amqp-binding/build.gradle +++ b/springwolf-bindings/springwolf-amqp-binding/build.gradle @@ -14,6 +14,8 @@ dependencies { implementation "org.springframework:spring-core" implementation "org.springframework.boot:spring-boot-autoconfigure" + implementation "org.apache.commons:commons-lang3:${commonsLang3Version}" + testImplementation "org.assertj:assertj-core:${assertjCoreVersion}" testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" From 69726cc09cf128bf3b236c26f1b4a65bb2949aff Mon Sep 17 00:00:00 2001 From: Timon Back Date: Sat, 27 Apr 2024 22:00:09 +0200 Subject: [PATCH 3/7] feat: add kafka bindings artifact --- springwolf-bindings/springwolf-kafka-binding/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/springwolf-bindings/springwolf-kafka-binding/build.gradle b/springwolf-bindings/springwolf-kafka-binding/build.gradle index d09057956..525f1551d 100644 --- a/springwolf-bindings/springwolf-kafka-binding/build.gradle +++ b/springwolf-bindings/springwolf-kafka-binding/build.gradle @@ -14,6 +14,8 @@ dependencies { implementation "org.springframework:spring-core" implementation "org.springframework.boot:spring-boot-autoconfigure" + implementation "org.apache.commons:commons-lang3:${commonsLang3Version}" + testImplementation "org.assertj:assertj-core:${assertjCoreVersion}" testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" From 582b113f66d78e3337e2aed2ddb9b68d6149f16b Mon Sep 17 00:00:00 2001 From: Timon Back Date: Sat, 27 Apr 2024 22:03:23 +0200 Subject: [PATCH 4/7] chore: update bindings dependencies --- springwolf-bindings/springwolf-amqp-binding/build.gradle | 2 -- springwolf-bindings/springwolf-jms-binding/build.gradle | 2 -- springwolf-bindings/springwolf-kafka-binding/build.gradle | 2 -- 3 files changed, 6 deletions(-) diff --git a/springwolf-bindings/springwolf-amqp-binding/build.gradle b/springwolf-bindings/springwolf-amqp-binding/build.gradle index 762299e1d..4b92963bc 100644 --- a/springwolf-bindings/springwolf-amqp-binding/build.gradle +++ b/springwolf-bindings/springwolf-amqp-binding/build.gradle @@ -14,8 +14,6 @@ dependencies { implementation "org.springframework:spring-core" implementation "org.springframework.boot:spring-boot-autoconfigure" - implementation "org.apache.commons:commons-lang3:${commonsLang3Version}" - testImplementation "org.assertj:assertj-core:${assertjCoreVersion}" testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" diff --git a/springwolf-bindings/springwolf-jms-binding/build.gradle b/springwolf-bindings/springwolf-jms-binding/build.gradle index c02af05a8..d3ed9398d 100644 --- a/springwolf-bindings/springwolf-jms-binding/build.gradle +++ b/springwolf-bindings/springwolf-jms-binding/build.gradle @@ -14,8 +14,6 @@ dependencies { implementation "org.springframework:spring-core" implementation "org.springframework.boot:spring-boot-autoconfigure" - implementation "org.apache.commons:commons-lang3:${commonsLang3Version}" - testImplementation "org.assertj:assertj-core:${assertjCoreVersion}" testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" diff --git a/springwolf-bindings/springwolf-kafka-binding/build.gradle b/springwolf-bindings/springwolf-kafka-binding/build.gradle index 525f1551d..d09057956 100644 --- a/springwolf-bindings/springwolf-kafka-binding/build.gradle +++ b/springwolf-bindings/springwolf-kafka-binding/build.gradle @@ -14,8 +14,6 @@ dependencies { implementation "org.springframework:spring-core" implementation "org.springframework.boot:spring-boot-autoconfigure" - implementation "org.apache.commons:commons-lang3:${commonsLang3Version}" - testImplementation "org.assertj:assertj-core:${assertjCoreVersion}" testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" From 7ca1dfd84fc5ddddebb3e6f34ea8299b5a20f316 Mon Sep 17 00:00:00 2001 From: Timon Back Date: Sat, 27 Apr 2024 22:19:21 +0200 Subject: [PATCH 5/7] chore!: replace bindings in plugins Instead use the new bindings artifacts This requires users to update the imports of the annotations --- .../amqp/producers/AnotherProducer.java | 2 +- .../jms/producers/AnotherProducer.java | 2 +- .../kafka/consumers/AvroConsumer.java | 2 +- .../ExampleClassLevelKafkaListener.java | 2 +- .../kafka/consumers/StringConsumer.java | 2 +- .../examples/kafka/consumers/XmlConsumer.java | 2 +- .../kafka/consumers/YamlConsumer.java | 2 +- .../kafka/producers/NestedProducer.java | 2 +- .../sns/consumers/ExampleConsumer.java | 4 +- .../sns/producers/AnotherProducer.java | 4 +- .../sqs/producers/AnotherProducer.java | 4 +- .../springwolf-amqp-plugin/build.gradle | 1 + .../AmqpAsyncOperationBinding.java | 37 ---------- .../messages/AmqpMessageBindingProcessor.java | 37 ---------- .../AmqpOperationBindingProcessor.java | 28 -------- .../SpringwolfAmqpScannerConfiguration.java | 16 ----- .../AmqpMessageBindingProcessorTest.java | 40 ----------- .../AmqpOperationBindingProcessorTest.java | 38 ---------- .../springwolf-jms-plugin/build.gradle | 1 + .../annotations/JmsAsyncOperationBinding.java | 20 ------ .../messages/JmsMessageBindingProcessor.java | 37 ---------- .../JmsOperationBindingProcessor.java | 15 ---- .../SpringwolfJmsScannerConfiguration.java | 17 ----- .../JmsMessageBindingProcessorTest.java | 40 ----------- .../JmsOperationBindingProcessorTest.java | 28 -------- .../springwolf-kafka-plugin/build.gradle | 1 + .../KafkaAsyncOperationBinding.java | 56 --------------- .../KafkaMessageBindingProcessor.java | 70 ------------------- .../KafkaOperationBindingProcessor.java | 30 -------- .../SpringwolfKafkaScannerConfiguration.java | 15 ---- .../KafkaMessageBindingProcessorTest.java | 40 ----------- .../KafkaOperationBindingProcessorTest.java | 28 -------- .../springwolf-sns-plugin/build.gradle | 1 + .../annotations/SnsAsyncOperationBinding.java | 29 -------- .../SnsAsyncOperationBindingIdentifier.java | 42 ----------- .../messages/SnsMessageBindingProcessor.java | 35 ---------- .../SnsOperationBindingProcessor.java | 56 --------------- .../SpringwolfSnsAutoConfiguration.java | 2 +- .../SpringwolfSnsScannerConfiguration.java | 31 -------- .../SnsMessageBindingProcessorTest.java | 41 ----------- .../SnsOperationBindingProcessorTest.java | 41 ----------- .../springwolf-sqs-plugin/build.gradle | 1 + .../annotations/SqsAsyncOperationBinding.java | 25 ------- .../sqs/annotations/SqsAsyncQueueBinding.java | 20 ------ .../messages/SqsMessageBindingProcessor.java | 37 ---------- .../SqsOperationBindingProcessor.java | 28 -------- .../SpringwolfSqsScannerConfiguration.java | 17 ----- .../SqsMessageBindingProcessorTest.java | 40 ----------- .../SqsOperationBindingProcessorTest.java | 39 ----------- 49 files changed, 20 insertions(+), 1088 deletions(-) delete mode 100644 springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/asyncapi/annotations/AmqpAsyncOperationBinding.java delete mode 100644 springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/bindings/messages/AmqpMessageBindingProcessor.java delete mode 100644 springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/bindings/operations/AmqpOperationBindingProcessor.java delete mode 100644 springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/bindings/messages/AmqpMessageBindingProcessorTest.java delete mode 100644 springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/bindings/operations/AmqpOperationBindingProcessorTest.java delete mode 100644 springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/asyncapi/annotations/JmsAsyncOperationBinding.java delete mode 100644 springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/asyncapi/scanners/bindings/messages/JmsMessageBindingProcessor.java delete mode 100644 springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/asyncapi/scanners/bindings/operations/JmsOperationBindingProcessor.java delete mode 100644 springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/asyncapi/scanners/bindings/messages/JmsMessageBindingProcessorTest.java delete mode 100644 springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/asyncapi/scanners/bindings/operations/JmsOperationBindingProcessorTest.java delete mode 100644 springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/annotations/KafkaAsyncOperationBinding.java delete mode 100644 springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/bindings/messages/KafkaMessageBindingProcessor.java delete mode 100644 springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/bindings/operations/KafkaOperationBindingProcessor.java delete mode 100644 springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/bindings/messages/KafkaMessageBindingProcessorTest.java delete mode 100644 springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/bindings/operations/KafkaOperationBindingProcessorTest.java delete mode 100644 springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/annotations/SnsAsyncOperationBinding.java delete mode 100644 springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/annotations/SnsAsyncOperationBindingIdentifier.java delete mode 100644 springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/asyncapi/scanners/bindings/messages/SnsMessageBindingProcessor.java delete mode 100644 springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/asyncapi/scanners/bindings/operations/SnsOperationBindingProcessor.java delete mode 100644 springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/configuration/SpringwolfSnsScannerConfiguration.java delete mode 100644 springwolf-plugins/springwolf-sns-plugin/src/test/java/io/github/springwolf/plugins/sns/asyncapi/scanners/bindings/messages/SnsMessageBindingProcessorTest.java delete mode 100644 springwolf-plugins/springwolf-sns-plugin/src/test/java/io/github/springwolf/plugins/sns/asyncapi/scanners/bindings/operations/SnsOperationBindingProcessorTest.java delete mode 100644 springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/annotations/SqsAsyncOperationBinding.java delete mode 100644 springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/annotations/SqsAsyncQueueBinding.java delete mode 100644 springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/asyncapi/scanners/bindings/messages/SqsMessageBindingProcessor.java delete mode 100644 springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/asyncapi/scanners/bindings/operations/SqsOperationBindingProcessor.java delete mode 100644 springwolf-plugins/springwolf-sqs-plugin/src/test/java/io/github/springwolf/plugins/sqs/asyncapi/scanners/bindings/messages/SqsMessageBindingProcessorTest.java delete mode 100644 springwolf-plugins/springwolf-sqs-plugin/src/test/java/io/github/springwolf/plugins/sqs/asyncapi/scanners/bindings/operations/SqsOperationBindingProcessorTest.java diff --git a/springwolf-examples/springwolf-amqp-example/src/main/java/io/github/springwolf/examples/amqp/producers/AnotherProducer.java b/springwolf-examples/springwolf-amqp-example/src/main/java/io/github/springwolf/examples/amqp/producers/AnotherProducer.java index 52cff853d..c2b200ae3 100644 --- a/springwolf-examples/springwolf-amqp-example/src/main/java/io/github/springwolf/examples/amqp/producers/AnotherProducer.java +++ b/springwolf-examples/springwolf-amqp-example/src/main/java/io/github/springwolf/examples/amqp/producers/AnotherProducer.java @@ -1,10 +1,10 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.springwolf.examples.amqp.producers; +import io.github.springwolf.bindings.amqp.annotations.AmqpAsyncOperationBinding; import io.github.springwolf.core.asyncapi.annotations.AsyncOperation; import io.github.springwolf.core.asyncapi.annotations.AsyncPublisher; import io.github.springwolf.examples.amqp.dtos.AnotherPayloadDto; -import io.github.springwolf.plugins.amqp.asyncapi.annotations.AmqpAsyncOperationBinding; import lombok.RequiredArgsConstructor; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.stereotype.Component; diff --git a/springwolf-examples/springwolf-jms-example/src/main/java/io/github/springwolf/examples/jms/producers/AnotherProducer.java b/springwolf-examples/springwolf-jms-example/src/main/java/io/github/springwolf/examples/jms/producers/AnotherProducer.java index 04e577a33..0d63145c6 100644 --- a/springwolf-examples/springwolf-jms-example/src/main/java/io/github/springwolf/examples/jms/producers/AnotherProducer.java +++ b/springwolf-examples/springwolf-jms-example/src/main/java/io/github/springwolf/examples/jms/producers/AnotherProducer.java @@ -2,10 +2,10 @@ package io.github.springwolf.examples.jms.producers; import io.github.springwolf.addons.generic_binding.annotation.AsyncGenericOperationBinding; +import io.github.springwolf.bindings.jms.annotations.JmsAsyncOperationBinding; import io.github.springwolf.core.asyncapi.annotations.AsyncOperation; import io.github.springwolf.core.asyncapi.annotations.AsyncPublisher; import io.github.springwolf.examples.jms.dtos.AnotherPayloadDto; -import io.github.springwolf.plugins.jms.asyncapi.annotations.JmsAsyncOperationBinding; import lombok.RequiredArgsConstructor; import org.springframework.jms.core.JmsTemplate; import org.springframework.stereotype.Component; diff --git a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/AvroConsumer.java b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/AvroConsumer.java index 2f0132e0f..5b82956cd 100644 --- a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/AvroConsumer.java +++ b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/AvroConsumer.java @@ -1,10 +1,10 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.springwolf.examples.kafka.consumers; +import io.github.springwolf.bindings.kafka.annotations.KafkaAsyncOperationBinding; import io.github.springwolf.core.asyncapi.annotations.AsyncListener; import io.github.springwolf.core.asyncapi.annotations.AsyncOperation; import io.github.springwolf.examples.kafka.dto.avro.AnotherPayloadAvroDto; -import io.github.springwolf.plugins.kafka.asyncapi.annotations.KafkaAsyncOperationBinding; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.kafka.annotation.KafkaListener; diff --git a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/ExampleClassLevelKafkaListener.java b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/ExampleClassLevelKafkaListener.java index 2ee51715d..532b547e9 100644 --- a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/ExampleClassLevelKafkaListener.java +++ b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/ExampleClassLevelKafkaListener.java @@ -1,11 +1,11 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.springwolf.examples.kafka.consumers; +import io.github.springwolf.bindings.kafka.annotations.KafkaAsyncOperationBinding; import io.github.springwolf.core.asyncapi.annotations.AsyncListener; import io.github.springwolf.core.asyncapi.annotations.AsyncOperation; import io.github.springwolf.examples.kafka.dtos.AnotherPayloadDto; import io.github.springwolf.examples.kafka.dtos.ExamplePayloadDto; -import io.github.springwolf.plugins.kafka.asyncapi.annotations.KafkaAsyncOperationBinding; import lombok.extern.slf4j.Slf4j; import org.springframework.kafka.annotation.KafkaHandler; import org.springframework.kafka.annotation.KafkaListener; diff --git a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/StringConsumer.java b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/StringConsumer.java index 72598d3ac..38208e70c 100644 --- a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/StringConsumer.java +++ b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/StringConsumer.java @@ -1,11 +1,11 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.springwolf.examples.kafka.consumers; +import io.github.springwolf.bindings.kafka.annotations.KafkaAsyncOperationBinding; import io.github.springwolf.core.asyncapi.annotations.AsyncApiPayload; import io.github.springwolf.core.asyncapi.annotations.AsyncListener; import io.github.springwolf.core.asyncapi.annotations.AsyncMessage; import io.github.springwolf.core.asyncapi.annotations.AsyncOperation; -import io.github.springwolf.plugins.kafka.asyncapi.annotations.KafkaAsyncOperationBinding; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/XmlConsumer.java b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/XmlConsumer.java index ef091867c..3ca0e88a8 100644 --- a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/XmlConsumer.java +++ b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/XmlConsumer.java @@ -1,11 +1,11 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.springwolf.examples.kafka.consumers; +import io.github.springwolf.bindings.kafka.annotations.KafkaAsyncOperationBinding; import io.github.springwolf.core.asyncapi.annotations.AsyncListener; import io.github.springwolf.core.asyncapi.annotations.AsyncMessage; import io.github.springwolf.core.asyncapi.annotations.AsyncOperation; import io.github.springwolf.examples.kafka.dtos.XmlPayloadDto; -import io.github.springwolf.plugins.kafka.asyncapi.annotations.KafkaAsyncOperationBinding; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.kafka.annotation.KafkaListener; diff --git a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/YamlConsumer.java b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/YamlConsumer.java index ea847da43..98fe448c2 100644 --- a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/YamlConsumer.java +++ b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/consumers/YamlConsumer.java @@ -1,11 +1,11 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.springwolf.examples.kafka.consumers; +import io.github.springwolf.bindings.kafka.annotations.KafkaAsyncOperationBinding; import io.github.springwolf.core.asyncapi.annotations.AsyncListener; import io.github.springwolf.core.asyncapi.annotations.AsyncMessage; import io.github.springwolf.core.asyncapi.annotations.AsyncOperation; import io.github.springwolf.examples.kafka.dtos.YamlPayloadDto; -import io.github.springwolf.plugins.kafka.asyncapi.annotations.KafkaAsyncOperationBinding; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.kafka.annotation.KafkaListener; diff --git a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/producers/NestedProducer.java b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/producers/NestedProducer.java index 8487cbfb4..06aba8eec 100644 --- a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/producers/NestedProducer.java +++ b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/producers/NestedProducer.java @@ -1,12 +1,12 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.springwolf.examples.kafka.producers; +import io.github.springwolf.bindings.kafka.annotations.KafkaAsyncOperationBinding; import io.github.springwolf.core.asyncapi.annotations.AsyncOperation; import io.github.springwolf.core.asyncapi.annotations.AsyncPublisher; import io.github.springwolf.core.asyncapi.scanners.common.headers.AsyncHeadersCloudEventConstants; import io.github.springwolf.examples.kafka.configuration.KafkaConfiguration; import io.github.springwolf.examples.kafka.dtos.NestedPayloadDto; -import io.github.springwolf.plugins.kafka.asyncapi.annotations.KafkaAsyncOperationBinding; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.kafka.core.KafkaTemplate; diff --git a/springwolf-examples/springwolf-sns-example/src/main/java/io/github/springwolf/examples/sns/consumers/ExampleConsumer.java b/springwolf-examples/springwolf-sns-example/src/main/java/io/github/springwolf/examples/sns/consumers/ExampleConsumer.java index 3590c8f74..23a3a4c86 100644 --- a/springwolf-examples/springwolf-sns-example/src/main/java/io/github/springwolf/examples/sns/consumers/ExampleConsumer.java +++ b/springwolf-examples/springwolf-sns-example/src/main/java/io/github/springwolf/examples/sns/consumers/ExampleConsumer.java @@ -1,13 +1,13 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.springwolf.examples.sns.consumers; +import io.github.springwolf.bindings.sns.annotations.SnsAsyncOperationBinding; +import io.github.springwolf.bindings.sns.annotations.SnsAsyncOperationBindingIdentifier; import io.github.springwolf.core.asyncapi.annotations.AsyncListener; import io.github.springwolf.core.asyncapi.annotations.AsyncOperation; import io.github.springwolf.examples.sns.dtos.AnotherPayloadDto; import io.github.springwolf.examples.sns.dtos.ExamplePayloadDto; import io.github.springwolf.examples.sns.producers.AnotherProducer; -import io.github.springwolf.plugins.sns.annotations.SnsAsyncOperationBinding; -import io.github.springwolf.plugins.sns.annotations.SnsAsyncOperationBindingIdentifier; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; diff --git a/springwolf-examples/springwolf-sns-example/src/main/java/io/github/springwolf/examples/sns/producers/AnotherProducer.java b/springwolf-examples/springwolf-sns-example/src/main/java/io/github/springwolf/examples/sns/producers/AnotherProducer.java index 573fb95c9..62c866585 100644 --- a/springwolf-examples/springwolf-sns-example/src/main/java/io/github/springwolf/examples/sns/producers/AnotherProducer.java +++ b/springwolf-examples/springwolf-sns-example/src/main/java/io/github/springwolf/examples/sns/producers/AnotherProducer.java @@ -2,11 +2,11 @@ package io.github.springwolf.examples.sns.producers; import io.awspring.cloud.sns.core.SnsTemplate; +import io.github.springwolf.bindings.sns.annotations.SnsAsyncOperationBinding; +import io.github.springwolf.bindings.sns.annotations.SnsAsyncOperationBindingIdentifier; import io.github.springwolf.core.asyncapi.annotations.AsyncOperation; import io.github.springwolf.core.asyncapi.annotations.AsyncPublisher; import io.github.springwolf.examples.sns.dtos.AnotherPayloadDto; -import io.github.springwolf.plugins.sns.annotations.SnsAsyncOperationBinding; -import io.github.springwolf.plugins.sns.annotations.SnsAsyncOperationBindingIdentifier; import lombok.RequiredArgsConstructor; import org.springframework.messaging.support.MessageBuilder; import org.springframework.stereotype.Component; diff --git a/springwolf-examples/springwolf-sqs-example/src/main/java/io/github/springwolf/examples/sqs/producers/AnotherProducer.java b/springwolf-examples/springwolf-sqs-example/src/main/java/io/github/springwolf/examples/sqs/producers/AnotherProducer.java index d07e77934..d268a64e6 100644 --- a/springwolf-examples/springwolf-sqs-example/src/main/java/io/github/springwolf/examples/sqs/producers/AnotherProducer.java +++ b/springwolf-examples/springwolf-sqs-example/src/main/java/io/github/springwolf/examples/sqs/producers/AnotherProducer.java @@ -2,11 +2,11 @@ package io.github.springwolf.examples.sqs.producers; import io.awspring.cloud.sqs.operations.SqsTemplate; +import io.github.springwolf.bindings.sqs.annotations.SqsAsyncOperationBinding; +import io.github.springwolf.bindings.sqs.annotations.SqsAsyncQueueBinding; import io.github.springwolf.core.asyncapi.annotations.AsyncOperation; import io.github.springwolf.core.asyncapi.annotations.AsyncPublisher; import io.github.springwolf.examples.sqs.dtos.AnotherPayloadDto; -import io.github.springwolf.plugins.sqs.annotations.SqsAsyncOperationBinding; -import io.github.springwolf.plugins.sqs.annotations.SqsAsyncQueueBinding; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; diff --git a/springwolf-plugins/springwolf-amqp-plugin/build.gradle b/springwolf-plugins/springwolf-amqp-plugin/build.gradle index 0cc0d8513..77817efa9 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/build.gradle +++ b/springwolf-plugins/springwolf-amqp-plugin/build.gradle @@ -9,6 +9,7 @@ plugins { dependencies { api project(":springwolf-core") api project(":springwolf-asyncapi") + api project(":springwolf-bindings:springwolf-amqp-binding") implementation "org.slf4j:slf4j-api:${slf4jApiVersion}" diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/asyncapi/annotations/AmqpAsyncOperationBinding.java b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/asyncapi/annotations/AmqpAsyncOperationBinding.java deleted file mode 100644 index 8fdd8951a..000000000 --- a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/asyncapi/annotations/AmqpAsyncOperationBinding.java +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.amqp.asyncapi.annotations; - -import io.github.springwolf.core.asyncapi.annotations.AsyncListener; -import io.github.springwolf.core.asyncapi.annotations.AsyncOperationBinding; -import io.github.springwolf.core.asyncapi.annotations.AsyncPublisher; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * {@code @AmqpAsyncOperationBinding} is a method-level annotation used in combination with {@link AsyncPublisher} or {@link AsyncListener}. - * It configures the operation binding for the AMQP protocol. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(value = {ElementType.METHOD, ElementType.ANNOTATION_TYPE}) -@AsyncOperationBinding -@Inherited -public @interface AmqpAsyncOperationBinding { - - int expiration() default 0; - - String[] cc() default {}; - - int priority() default 0; - - int deliveryMode() default 1; - - boolean mandatory() default false; - - boolean timestamp() default false; - - boolean ack() default false; -} diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/bindings/messages/AmqpMessageBindingProcessor.java b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/bindings/messages/AmqpMessageBindingProcessor.java deleted file mode 100644 index ee98112d3..000000000 --- a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/bindings/messages/AmqpMessageBindingProcessor.java +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.amqp.asyncapi.scanners.bindings.messages; - -import io.github.springwolf.asyncapi.v3.bindings.amqp.AMQPMessageBinding; -import io.github.springwolf.core.asyncapi.scanners.bindings.messages.MessageBindingProcessor; -import io.github.springwolf.core.asyncapi.scanners.bindings.messages.ProcessedMessageBinding; -import io.github.springwolf.plugins.amqp.asyncapi.annotations.AmqpAsyncOperationBinding; -import org.springframework.context.EmbeddedValueResolverAware; -import org.springframework.util.StringValueResolver; - -import java.lang.reflect.AnnotatedElement; -import java.util.Arrays; -import java.util.Optional; - -public class AmqpMessageBindingProcessor implements MessageBindingProcessor, EmbeddedValueResolverAware { - private StringValueResolver resolver; - - @Override - public void setEmbeddedValueResolver(StringValueResolver resolver) { - this.resolver = resolver; - } - - @Override - public Optional process(AnnotatedElement annotatedElement) { - return Arrays.stream(annotatedElement.getAnnotations()) - .filter(AmqpAsyncOperationBinding.class::isInstance) - .map(AmqpAsyncOperationBinding.class::cast) - .findAny() - .map(this::mapToMessageBinding); - } - - private ProcessedMessageBinding mapToMessageBinding(AmqpAsyncOperationBinding bindingAnnotation) { - AMQPMessageBinding amqpMessageBinding = AMQPMessageBinding.builder().build(); - - return new ProcessedMessageBinding("amqp", amqpMessageBinding); - } -} diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/bindings/operations/AmqpOperationBindingProcessor.java b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/bindings/operations/AmqpOperationBindingProcessor.java deleted file mode 100644 index 21e139a60..000000000 --- a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/bindings/operations/AmqpOperationBindingProcessor.java +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.amqp.asyncapi.scanners.bindings.operations; - -import io.github.springwolf.asyncapi.v3.bindings.amqp.AMQPOperationBinding; -import io.github.springwolf.core.asyncapi.scanners.bindings.operations.AbstractOperationBindingProcessor; -import io.github.springwolf.core.asyncapi.scanners.bindings.operations.ProcessedOperationBinding; -import io.github.springwolf.plugins.amqp.asyncapi.annotations.AmqpAsyncOperationBinding; - -import java.util.Arrays; - -public class AmqpOperationBindingProcessor extends AbstractOperationBindingProcessor { - @Override - protected ProcessedOperationBinding mapToOperationBinding(AmqpAsyncOperationBinding bindingAnnotation) { - AMQPOperationBinding amqpOperationBinding = AMQPOperationBinding.builder() - .expiration(bindingAnnotation.expiration()) - .cc(Arrays.stream(bindingAnnotation.cc()) - .map(this::resolveOrNull) - .toList()) - .priority(bindingAnnotation.priority()) - .deliveryMode(bindingAnnotation.deliveryMode()) - .mandatory(bindingAnnotation.mandatory()) - .timestamp(bindingAnnotation.timestamp()) - .ack(bindingAnnotation.ack()) - .build(); - - return new ProcessedOperationBinding("amqp", amqpOperationBinding); - } -} diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/configuration/SpringwolfAmqpScannerConfiguration.java b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/configuration/SpringwolfAmqpScannerConfiguration.java index 415dbd9de..307e8027c 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/configuration/SpringwolfAmqpScannerConfiguration.java +++ b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/configuration/SpringwolfAmqpScannerConfiguration.java @@ -2,7 +2,6 @@ package io.github.springwolf.plugins.amqp.configuration; import io.github.springwolf.core.asyncapi.components.ComponentsService; -import io.github.springwolf.core.asyncapi.scanners.bindings.BindingProcessorPriority; import io.github.springwolf.core.asyncapi.scanners.channels.ChannelPriority; import io.github.springwolf.core.asyncapi.scanners.channels.SpringAnnotationChannelsScanner; import io.github.springwolf.core.asyncapi.scanners.channels.annotations.SpringAnnotationClassLevelChannelsScanner; @@ -21,7 +20,6 @@ import org.springframework.amqp.core.Queue; import org.springframework.amqp.rabbit.annotation.RabbitHandler; import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -148,18 +146,4 @@ public SpringAnnotationOperationsScanner simpleRabbitMethodLevelListenerAnnotati return new SpringAnnotationOperationsScanner(classScanner, strategy); } - - @Bean - @Order(value = BindingProcessorPriority.PROTOCOL_BINDING) - @ConditionalOnMissingBean - public AmqpMessageBindingProcessor amqpMessageBindingProcessor() { - return new AmqpMessageBindingProcessor(); - } - - @Bean - @Order(value = BindingProcessorPriority.PROTOCOL_BINDING) - @ConditionalOnMissingBean - public AmqpOperationBindingProcessor amqpOperationBindingProcessor() { - return new AmqpOperationBindingProcessor(); - } } diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/bindings/messages/AmqpMessageBindingProcessorTest.java b/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/bindings/messages/AmqpMessageBindingProcessorTest.java deleted file mode 100644 index b8f9fcda7..000000000 --- a/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/bindings/messages/AmqpMessageBindingProcessorTest.java +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.amqp.asyncapi.scanners.bindings.messages; - -import io.github.springwolf.asyncapi.v3.bindings.amqp.AMQPMessageBinding; -import io.github.springwolf.core.asyncapi.scanners.bindings.messages.ProcessedMessageBinding; -import io.github.springwolf.plugins.amqp.asyncapi.annotations.AmqpAsyncOperationBinding; -import org.junit.jupiter.api.Test; - -import java.lang.reflect.Method; -import java.util.Optional; - -import static org.assertj.core.api.Assertions.assertThat; - -class AmqpMessageBindingProcessorTest { - private final AmqpMessageBindingProcessor processor = new AmqpMessageBindingProcessor(); - - @Test - void processTest() throws NoSuchMethodException { - Method method = AmqpMessageBindingProcessorTest.class.getMethod("methodWithAnnotation"); - - ProcessedMessageBinding binding = processor.process(method).get(); - - assertThat(binding.getType()).isEqualTo("amqp"); - assertThat(binding.getBinding()).isEqualTo(new AMQPMessageBinding()); - } - - @Test - void processWithoutAnnotationTest() throws NoSuchMethodException { - Method method = AmqpMessageBindingProcessorTest.class.getMethod("methodWithoutAnnotation"); - - Optional binding = processor.process(method); - - assertThat(binding).isNotPresent(); - } - - @AmqpAsyncOperationBinding - public void methodWithAnnotation() {} - - public void methodWithoutAnnotation() {} -} diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/bindings/operations/AmqpOperationBindingProcessorTest.java b/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/bindings/operations/AmqpOperationBindingProcessorTest.java deleted file mode 100644 index 5ee4c6253..000000000 --- a/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/bindings/operations/AmqpOperationBindingProcessorTest.java +++ /dev/null @@ -1,38 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.amqp.asyncapi.scanners.bindings.operations; - -import io.github.springwolf.asyncapi.v3.bindings.amqp.AMQPOperationBinding; -import io.github.springwolf.core.asyncapi.scanners.bindings.operations.ProcessedOperationBinding; -import io.github.springwolf.plugins.amqp.asyncapi.annotations.AmqpAsyncOperationBinding; -import org.junit.jupiter.api.Test; - -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; - -class AmqpOperationBindingProcessorTest { - private final AmqpOperationBindingProcessor processor = new AmqpOperationBindingProcessor(); - - @Test - void mapToOperationBindingTest() throws NoSuchMethodException { - AmqpAsyncOperationBinding annotation = AmqpOperationBindingProcessorTest.class - .getMethod("methodWithAnnotation") - .getAnnotation(AmqpAsyncOperationBinding.class); - - ProcessedOperationBinding binding = processor.mapToOperationBinding(annotation); - - assertThat(binding.getType()).isEqualTo("amqp"); - assertThat(binding.getBinding()) - .isEqualTo(AMQPOperationBinding.builder() - .cc(List.of()) - .priority(0) - .deliveryMode(1) - .mandatory(false) - .timestamp(false) - .ack(false) - .build()); - } - - @AmqpAsyncOperationBinding - public void methodWithAnnotation() {} -} diff --git a/springwolf-plugins/springwolf-jms-plugin/build.gradle b/springwolf-plugins/springwolf-jms-plugin/build.gradle index f4c9b11dd..ab3284379 100644 --- a/springwolf-plugins/springwolf-jms-plugin/build.gradle +++ b/springwolf-plugins/springwolf-jms-plugin/build.gradle @@ -9,6 +9,7 @@ plugins { dependencies { api project(":springwolf-asyncapi") api project(":springwolf-core") + api project(":springwolf-bindings:springwolf-jms-binding") implementation "jakarta.jms:jakarta.jms-api" diff --git a/springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/asyncapi/annotations/JmsAsyncOperationBinding.java b/springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/asyncapi/annotations/JmsAsyncOperationBinding.java deleted file mode 100644 index 2f83fde65..000000000 --- a/springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/asyncapi/annotations/JmsAsyncOperationBinding.java +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.jms.asyncapi.annotations; - -import io.github.springwolf.core.asyncapi.annotations.AsyncListener; -import io.github.springwolf.core.asyncapi.annotations.AsyncOperationBinding; -import io.github.springwolf.core.asyncapi.annotations.AsyncPublisher; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * {@code @JmsAsyncOperationBinding} is a method-level annotation used in combination with {@link AsyncPublisher} or {@link AsyncListener}. - * It configures the operation binding for the JMS protocol. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(value = {ElementType.METHOD, ElementType.ANNOTATION_TYPE}) -@AsyncOperationBinding -public @interface JmsAsyncOperationBinding {} diff --git a/springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/asyncapi/scanners/bindings/messages/JmsMessageBindingProcessor.java b/springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/asyncapi/scanners/bindings/messages/JmsMessageBindingProcessor.java deleted file mode 100644 index 67ae8ce5c..000000000 --- a/springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/asyncapi/scanners/bindings/messages/JmsMessageBindingProcessor.java +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.jms.asyncapi.scanners.bindings.messages; - -import io.github.springwolf.asyncapi.v3.bindings.jms.JMSMessageBinding; -import io.github.springwolf.core.asyncapi.scanners.bindings.messages.MessageBindingProcessor; -import io.github.springwolf.core.asyncapi.scanners.bindings.messages.ProcessedMessageBinding; -import io.github.springwolf.plugins.jms.asyncapi.annotations.JmsAsyncOperationBinding; -import org.springframework.context.EmbeddedValueResolverAware; -import org.springframework.util.StringValueResolver; - -import java.lang.reflect.AnnotatedElement; -import java.util.Arrays; -import java.util.Optional; - -public class JmsMessageBindingProcessor implements MessageBindingProcessor, EmbeddedValueResolverAware { - private StringValueResolver resolver; - - @Override - public void setEmbeddedValueResolver(StringValueResolver resolver) { - this.resolver = resolver; - } - - @Override - public Optional process(AnnotatedElement annotatedElement) { - return Arrays.stream(annotatedElement.getAnnotations()) - .filter(annotation -> annotation instanceof JmsAsyncOperationBinding) - .map(annotation -> (JmsAsyncOperationBinding) annotation) - .findAny() - .map(this::mapToMessageBinding); - } - - private ProcessedMessageBinding mapToMessageBinding(JmsAsyncOperationBinding bindingAnnotation) { - JMSMessageBinding jmsMessageBinding = new JMSMessageBinding(); - - return new ProcessedMessageBinding("jms", jmsMessageBinding); - } -} diff --git a/springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/asyncapi/scanners/bindings/operations/JmsOperationBindingProcessor.java b/springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/asyncapi/scanners/bindings/operations/JmsOperationBindingProcessor.java deleted file mode 100644 index b01a50e21..000000000 --- a/springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/asyncapi/scanners/bindings/operations/JmsOperationBindingProcessor.java +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.jms.asyncapi.scanners.bindings.operations; - -import io.github.springwolf.asyncapi.v3.bindings.jms.JMSOperationBinding; -import io.github.springwolf.core.asyncapi.scanners.bindings.operations.AbstractOperationBindingProcessor; -import io.github.springwolf.core.asyncapi.scanners.bindings.operations.ProcessedOperationBinding; -import io.github.springwolf.plugins.jms.asyncapi.annotations.JmsAsyncOperationBinding; - -public class JmsOperationBindingProcessor extends AbstractOperationBindingProcessor { - - @Override - protected ProcessedOperationBinding mapToOperationBinding(JmsAsyncOperationBinding bindingAnnotation) { - return new ProcessedOperationBinding("jms", new JMSOperationBinding()); - } -} diff --git a/springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/configuration/SpringwolfJmsScannerConfiguration.java b/springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/configuration/SpringwolfJmsScannerConfiguration.java index edbb0056a..edbf54f54 100644 --- a/springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/configuration/SpringwolfJmsScannerConfiguration.java +++ b/springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/configuration/SpringwolfJmsScannerConfiguration.java @@ -12,9 +12,6 @@ import io.github.springwolf.core.asyncapi.scanners.operations.SpringAnnotationOperationsScanner; import io.github.springwolf.core.asyncapi.scanners.operations.annotations.SpringAnnotationMethodLevelOperationsScanner; import io.github.springwolf.plugins.jms.asyncapi.scanners.bindings.JmsBindingFactory; -import io.github.springwolf.plugins.jms.asyncapi.scanners.bindings.messages.JmsMessageBindingProcessor; -import io.github.springwolf.plugins.jms.asyncapi.scanners.bindings.operations.JmsOperationBindingProcessor; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -72,18 +69,4 @@ public SpringAnnotationOperationsScanner simpleJmsMethodLevelListenerAnnotationO return new SpringAnnotationOperationsScanner(classScanner, strategy); } - - @Bean - @Order(value = BindingProcessorPriority.PROTOCOL_BINDING) - @ConditionalOnMissingBean - public JmsMessageBindingProcessor jmsMessageBindingProcessor() { - return new JmsMessageBindingProcessor(); - } - - @Bean - @Order(value = BindingProcessorPriority.PROTOCOL_BINDING) - @ConditionalOnMissingBean - public JmsOperationBindingProcessor jmsOperationBindingProcessor() { - return new JmsOperationBindingProcessor(); - } } diff --git a/springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/asyncapi/scanners/bindings/messages/JmsMessageBindingProcessorTest.java b/springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/asyncapi/scanners/bindings/messages/JmsMessageBindingProcessorTest.java deleted file mode 100644 index 8e305213a..000000000 --- a/springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/asyncapi/scanners/bindings/messages/JmsMessageBindingProcessorTest.java +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.jms.asyncapi.scanners.bindings.messages; - -import io.github.springwolf.asyncapi.v3.bindings.jms.JMSMessageBinding; -import io.github.springwolf.core.asyncapi.scanners.bindings.messages.ProcessedMessageBinding; -import io.github.springwolf.plugins.jms.asyncapi.annotations.JmsAsyncOperationBinding; -import org.junit.jupiter.api.Test; - -import java.lang.reflect.Method; -import java.util.Optional; - -import static org.assertj.core.api.Assertions.assertThat; - -class JmsMessageBindingProcessorTest { - private final JmsMessageBindingProcessor processor = new JmsMessageBindingProcessor(); - - @Test - void processTest() throws NoSuchMethodException { - Method method = JmsMessageBindingProcessorTest.class.getMethod("methodWithAnnotation"); - - ProcessedMessageBinding binding = processor.process(method).get(); - - assertThat(binding.getType()).isEqualTo("jms"); - assertThat(binding.getBinding()).isEqualTo(new JMSMessageBinding()); - } - - @Test - void processWithoutAnnotationTest() throws NoSuchMethodException { - Method method = JmsMessageBindingProcessorTest.class.getMethod("methodWithoutAnnotation"); - - Optional binding = processor.process(method); - - assertThat(binding).isNotPresent(); - } - - @JmsAsyncOperationBinding - public void methodWithAnnotation() {} - - public void methodWithoutAnnotation() {} -} diff --git a/springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/asyncapi/scanners/bindings/operations/JmsOperationBindingProcessorTest.java b/springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/asyncapi/scanners/bindings/operations/JmsOperationBindingProcessorTest.java deleted file mode 100644 index 78842ded2..000000000 --- a/springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/asyncapi/scanners/bindings/operations/JmsOperationBindingProcessorTest.java +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.jms.asyncapi.scanners.bindings.operations; - -import io.github.springwolf.asyncapi.v3.bindings.jms.JMSOperationBinding; -import io.github.springwolf.core.asyncapi.scanners.bindings.operations.ProcessedOperationBinding; -import io.github.springwolf.plugins.jms.asyncapi.annotations.JmsAsyncOperationBinding; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -class JmsOperationBindingProcessorTest { - private final JmsOperationBindingProcessor processor = new JmsOperationBindingProcessor(); - - @Test - void mapToOperationBindingTest() throws NoSuchMethodException { - JmsAsyncOperationBinding annotation = JmsOperationBindingProcessorTest.class - .getMethod("methodWithAnnotation") - .getAnnotation(JmsAsyncOperationBinding.class); - - ProcessedOperationBinding binding = processor.mapToOperationBinding(annotation); - - assertThat(binding.getType()).isEqualTo("jms"); - assertThat(binding.getBinding()).isEqualTo(new JMSOperationBinding()); - } - - @JmsAsyncOperationBinding - public void methodWithAnnotation() {} -} diff --git a/springwolf-plugins/springwolf-kafka-plugin/build.gradle b/springwolf-plugins/springwolf-kafka-plugin/build.gradle index b20249df7..79c3517f5 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/build.gradle +++ b/springwolf-plugins/springwolf-kafka-plugin/build.gradle @@ -9,6 +9,7 @@ plugins { dependencies { api project(":springwolf-asyncapi") api project(":springwolf-core") + api project(":springwolf-bindings:springwolf-kafka-binding") implementation "io.swagger.core.v3:swagger-models-jakarta:${swaggerVersion}" permitUnusedDeclared "io.swagger.core.v3:swagger-models-jakarta:${swaggerVersion}" diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/annotations/KafkaAsyncOperationBinding.java b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/annotations/KafkaAsyncOperationBinding.java deleted file mode 100644 index 65275d08c..000000000 --- a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/annotations/KafkaAsyncOperationBinding.java +++ /dev/null @@ -1,56 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.kafka.asyncapi.annotations; - -import io.github.springwolf.core.asyncapi.annotations.AsyncListener; -import io.github.springwolf.core.asyncapi.annotations.AsyncOperationBinding; -import io.github.springwolf.core.asyncapi.annotations.AsyncPublisher; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * {@code @KafkaAsyncOperationBinding} is a method-level annotation used in combination with {@link AsyncPublisher} or @{@link AsyncListener}. - * It configures the operation binding for the Kafka protocol. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(value = {ElementType.METHOD, ElementType.ANNOTATION_TYPE}) -@AsyncOperationBinding -@Inherited -public @interface KafkaAsyncOperationBinding { - - String groupId() default ""; - - String clientId() default ""; - - String bindingVersion() default ""; - - KafkaAsyncMessageBinding messageBinding() default @KafkaAsyncMessageBinding(); - - @Retention(RetentionPolicy.CLASS) - @Target({}) - @interface KafkaAsyncMessageBinding { - - KafkaAsyncKey key() default @KafkaAsyncKey(type = KafkaAsyncKey.KafkaKeyTypes.UNDEFINED_KEY); - - String bindingVersion() default ""; - } - - @Retention(RetentionPolicy.CLASS) - @Target({}) - @interface KafkaAsyncKey { - - KafkaKeyTypes type() default KafkaKeyTypes.STRING_KEY; - - String example() default ""; - - String description() default ""; - - enum KafkaKeyTypes { - UNDEFINED_KEY, - STRING_KEY - } - } -} diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/bindings/messages/KafkaMessageBindingProcessor.java b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/bindings/messages/KafkaMessageBindingProcessor.java deleted file mode 100644 index b17d869c7..000000000 --- a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/bindings/messages/KafkaMessageBindingProcessor.java +++ /dev/null @@ -1,70 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.kafka.asyncapi.scanners.bindings.messages; - -import io.github.springwolf.asyncapi.v3.bindings.kafka.KafkaMessageBinding; -import io.github.springwolf.asyncapi.v3.model.schema.Schema; -import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; -import io.github.springwolf.core.asyncapi.scanners.bindings.messages.MessageBindingProcessor; -import io.github.springwolf.core.asyncapi.scanners.bindings.messages.ProcessedMessageBinding; -import io.github.springwolf.plugins.kafka.asyncapi.annotations.KafkaAsyncOperationBinding; -import org.springframework.context.EmbeddedValueResolverAware; -import org.springframework.util.StringUtils; -import org.springframework.util.StringValueResolver; - -import java.lang.reflect.AnnotatedElement; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -public class KafkaMessageBindingProcessor implements MessageBindingProcessor, EmbeddedValueResolverAware { - private StringValueResolver resolver; - - @Override - public void setEmbeddedValueResolver(StringValueResolver resolver) { - this.resolver = resolver; - } - - @Override - public Optional process(AnnotatedElement annotatedElement) { - return Arrays.stream(annotatedElement.getAnnotations()) - .filter(annotation -> annotation instanceof KafkaAsyncOperationBinding) - .map(annotation -> (KafkaAsyncOperationBinding) annotation) - .findAny() - .map(this::mapToMessageBinding); - } - - private ProcessedMessageBinding mapToMessageBinding(KafkaAsyncOperationBinding bindingAnnotation) { - KafkaAsyncOperationBinding.KafkaAsyncMessageBinding messageBinding = bindingAnnotation.messageBinding(); - - KafkaMessageBinding.KafkaMessageBindingBuilder kafkaMessageBindingBuilder = KafkaMessageBinding.builder(); - - kafkaMessageBindingBuilder.key(resolveSchemaOrNull(messageBinding)); - - String bindingVersion = resolveOrNull(messageBinding.bindingVersion()); - if (StringUtils.hasText(bindingVersion)) { - kafkaMessageBindingBuilder.bindingVersion(bindingVersion); - } - - return new ProcessedMessageBinding("kafka", kafkaMessageBindingBuilder.build()); - } - - private String resolveOrNull(String stringValue) { - return StringUtils.hasText(stringValue) ? resolver.resolveStringValue(stringValue) : null; - } - - private Schema resolveSchemaOrNull(KafkaAsyncOperationBinding.KafkaAsyncMessageBinding messageBinding) { - Schema schemaDefinition = null; - switch (messageBinding.key().type()) { - case UNDEFINED_KEY: - break; - case STRING_KEY: - schemaDefinition = SchemaObject.builder() - .type("string") - .examples(List.of(messageBinding.key().example())) - .description(resolveOrNull(messageBinding.key().description())) - .build(); - } - - return schemaDefinition; - } -} diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/bindings/operations/KafkaOperationBindingProcessor.java b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/bindings/operations/KafkaOperationBindingProcessor.java deleted file mode 100644 index 8a6940b20..000000000 --- a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/bindings/operations/KafkaOperationBindingProcessor.java +++ /dev/null @@ -1,30 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.kafka.asyncapi.scanners.bindings.operations; - -import io.github.springwolf.asyncapi.v3.bindings.kafka.KafkaOperationBinding; -import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; -import io.github.springwolf.core.asyncapi.scanners.bindings.operations.AbstractOperationBindingProcessor; -import io.github.springwolf.core.asyncapi.scanners.bindings.operations.ProcessedOperationBinding; -import io.github.springwolf.plugins.kafka.asyncapi.annotations.KafkaAsyncOperationBinding; -import io.github.springwolf.plugins.kafka.asyncapi.scanners.common.KafkaListenerUtil; -import org.springframework.util.StringUtils; - -public class KafkaOperationBindingProcessor extends AbstractOperationBindingProcessor { - @Override - protected ProcessedOperationBinding mapToOperationBinding(KafkaAsyncOperationBinding bindingAnnotation) { - String clientId = resolveOrNull(bindingAnnotation.clientId()); - SchemaObject clientIdSchema = KafkaListenerUtil.buildKafkaClientIdSchema(clientId); - String groupId = resolveOrNull(bindingAnnotation.groupId()); - SchemaObject groupIdSchema = KafkaListenerUtil.buildKafkaGroupIdSchema(groupId); - - KafkaOperationBinding.KafkaOperationBindingBuilder kafkaOperationBindingBuilder = - KafkaOperationBinding.builder(); - kafkaOperationBindingBuilder.clientId(clientIdSchema).groupId(groupIdSchema); - String bindingVersion = resolveOrNull(bindingAnnotation.bindingVersion()); - if (StringUtils.hasText(bindingVersion)) { - kafkaOperationBindingBuilder.bindingVersion(bindingVersion); - } - - return new ProcessedOperationBinding("kafka", kafkaOperationBindingBuilder.build()); - } -} diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/configuration/SpringwolfKafkaScannerConfiguration.java b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/configuration/SpringwolfKafkaScannerConfiguration.java index f24d2cef3..14c748169 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/configuration/SpringwolfKafkaScannerConfiguration.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/configuration/SpringwolfKafkaScannerConfiguration.java @@ -2,7 +2,6 @@ package io.github.springwolf.plugins.kafka.configuration; import io.github.springwolf.core.asyncapi.components.ComponentsService; -import io.github.springwolf.core.asyncapi.scanners.bindings.BindingProcessorPriority; import io.github.springwolf.core.asyncapi.scanners.channels.ChannelPriority; import io.github.springwolf.core.asyncapi.scanners.channels.SpringAnnotationChannelsScanner; import io.github.springwolf.core.asyncapi.scanners.channels.annotations.SpringAnnotationClassLevelChannelsScanner; @@ -143,18 +142,4 @@ public SpringAnnotationOperationsScanner simpleKafkaMethodLevelListenerAnnotatio return new SpringAnnotationOperationsScanner(classScanner, strategy); } - - @Bean - @Order(value = BindingProcessorPriority.PROTOCOL_BINDING) - @ConditionalOnMissingBean - public KafkaMessageBindingProcessor kafkaMessageBindingProcessor() { - return new KafkaMessageBindingProcessor(); - } - - @Bean - @Order(value = BindingProcessorPriority.PROTOCOL_BINDING) - @ConditionalOnMissingBean - public KafkaOperationBindingProcessor kafkaOperationBindingProcessor() { - return new KafkaOperationBindingProcessor(); - } } diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/bindings/messages/KafkaMessageBindingProcessorTest.java b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/bindings/messages/KafkaMessageBindingProcessorTest.java deleted file mode 100644 index 99058b09c..000000000 --- a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/bindings/messages/KafkaMessageBindingProcessorTest.java +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.kafka.asyncapi.scanners.bindings.messages; - -import io.github.springwolf.asyncapi.v3.bindings.kafka.KafkaMessageBinding; -import io.github.springwolf.core.asyncapi.scanners.bindings.messages.ProcessedMessageBinding; -import io.github.springwolf.plugins.kafka.asyncapi.annotations.KafkaAsyncOperationBinding; -import org.junit.jupiter.api.Test; - -import java.lang.reflect.Method; -import java.util.Optional; - -import static org.assertj.core.api.Assertions.assertThat; - -class KafkaMessageBindingProcessorTest { - private final KafkaMessageBindingProcessor processor = new KafkaMessageBindingProcessor(); - - @Test - void processTest() throws NoSuchMethodException { - Method method = KafkaMessageBindingProcessorTest.class.getMethod("methodWithAnnotation"); - - ProcessedMessageBinding binding = processor.process(method).get(); - - assertThat(binding.getType()).isEqualTo("kafka"); - assertThat(binding.getBinding()).isEqualTo(new KafkaMessageBinding()); - } - - @Test - void processWithoutAnnotationTest() throws NoSuchMethodException { - Method method = KafkaMessageBindingProcessorTest.class.getMethod("methodWithoutAnnotation"); - - Optional binding = processor.process(method); - - assertThat(binding).isNotPresent(); - } - - @KafkaAsyncOperationBinding - public void methodWithAnnotation() {} - - public void methodWithoutAnnotation() {} -} diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/bindings/operations/KafkaOperationBindingProcessorTest.java b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/bindings/operations/KafkaOperationBindingProcessorTest.java deleted file mode 100644 index dc2f9c43a..000000000 --- a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/bindings/operations/KafkaOperationBindingProcessorTest.java +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.kafka.asyncapi.scanners.bindings.operations; - -import io.github.springwolf.asyncapi.v3.bindings.kafka.KafkaOperationBinding; -import io.github.springwolf.core.asyncapi.scanners.bindings.operations.ProcessedOperationBinding; -import io.github.springwolf.plugins.kafka.asyncapi.annotations.KafkaAsyncOperationBinding; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -class KafkaOperationBindingProcessorTest { - private final KafkaOperationBindingProcessor processor = new KafkaOperationBindingProcessor(); - - @Test - void mapToOperationBindingTest() throws NoSuchMethodException { - KafkaAsyncOperationBinding annotation = KafkaOperationBindingProcessorTest.class - .getMethod("methodWithAnnotation") - .getAnnotation(KafkaAsyncOperationBinding.class); - - ProcessedOperationBinding binding = processor.mapToOperationBinding(annotation); - - assertThat(binding.getType()).isEqualTo("kafka"); - assertThat(binding.getBinding()).isEqualTo(new KafkaOperationBinding()); - } - - @KafkaAsyncOperationBinding - public void methodWithAnnotation() {} -} diff --git a/springwolf-plugins/springwolf-sns-plugin/build.gradle b/springwolf-plugins/springwolf-sns-plugin/build.gradle index 331b6c31a..82ca77c11 100644 --- a/springwolf-plugins/springwolf-sns-plugin/build.gradle +++ b/springwolf-plugins/springwolf-sns-plugin/build.gradle @@ -15,6 +15,7 @@ dependencyManagement { dependencies { api project(":springwolf-asyncapi") api project(":springwolf-core") + api project(":springwolf-bindings:springwolf-sns-binding") implementation "org.slf4j:slf4j-api:${slf4jApiVersion}" diff --git a/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/annotations/SnsAsyncOperationBinding.java b/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/annotations/SnsAsyncOperationBinding.java deleted file mode 100644 index a5b93c9d2..000000000 --- a/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/annotations/SnsAsyncOperationBinding.java +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.sns.annotations; - -import io.github.springwolf.core.asyncapi.annotations.AsyncListener; -import io.github.springwolf.core.asyncapi.annotations.AsyncOperationBinding; -import io.github.springwolf.core.asyncapi.annotations.AsyncPublisher; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * {@code @SnsAsyncOperationBinding} is a method-level annotation used in combination with {@link AsyncPublisher} or {@link AsyncListener}. - * It configures the operation binding for the SNS protocol. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(value = {ElementType.METHOD, ElementType.ANNOTATION_TYPE}) -@AsyncOperationBinding -@Inherited -public @interface SnsAsyncOperationBinding { - - String protocol(); - - SnsAsyncOperationBindingIdentifier endpoint(); - - boolean rawMessageDelivery() default true; -} diff --git a/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/annotations/SnsAsyncOperationBindingIdentifier.java b/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/annotations/SnsAsyncOperationBindingIdentifier.java deleted file mode 100644 index 03c01e94c..000000000 --- a/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/annotations/SnsAsyncOperationBindingIdentifier.java +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.sns.annotations; - -import io.github.springwolf.asyncapi.v3.bindings.sns.SNSOperationBindingIdentifier; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * @see SNSOperationBindingIdentifier - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.PARAMETER}) -@Inherited -public @interface SnsAsyncOperationBindingIdentifier { - /** - * Optional. The endpoint is a URL - */ - String url() default ""; - /** - * Optional. The endpoint is an email address - */ - String email() default ""; - /** - * Optional. The endpoint is a phone number - */ - String phone() default ""; - /** - * Optional. The target is an ARN. For example, for SQS, the identifier may be an ARN, which will be of the form: - * "arn:aws:sqs:{region}:{account-id}:{queueName}" - */ - String arn() default ""; - /** - * Optional. The endpoint is identified by a name, which corresponds to an identifying field called 'name' of a - * binding for that protocol on this publish Operation Object. For example, if the protocol is 'sqs' then the name - * refers to the name field sqs binding. We don't use $ref because we are referring, not including. - */ - String name() default ""; -} diff --git a/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/asyncapi/scanners/bindings/messages/SnsMessageBindingProcessor.java b/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/asyncapi/scanners/bindings/messages/SnsMessageBindingProcessor.java deleted file mode 100644 index 0c8dfab7b..000000000 --- a/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/asyncapi/scanners/bindings/messages/SnsMessageBindingProcessor.java +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.sns.asyncapi.scanners.bindings.messages; - -import io.github.springwolf.asyncapi.v3.bindings.sns.SNSMessageBinding; -import io.github.springwolf.core.asyncapi.scanners.bindings.messages.MessageBindingProcessor; -import io.github.springwolf.core.asyncapi.scanners.bindings.messages.ProcessedMessageBinding; -import io.github.springwolf.plugins.sns.annotations.SnsAsyncOperationBinding; -import org.springframework.context.EmbeddedValueResolverAware; -import org.springframework.util.StringValueResolver; - -import java.lang.reflect.AnnotatedElement; -import java.util.Arrays; -import java.util.Optional; - -public class SnsMessageBindingProcessor implements MessageBindingProcessor, EmbeddedValueResolverAware { - private StringValueResolver resolver; - - @Override - public void setEmbeddedValueResolver(StringValueResolver resolver) { - this.resolver = resolver; - } - - @Override - public Optional process(AnnotatedElement annotatedElement) { - return Arrays.stream(annotatedElement.getAnnotations()) - .filter(SnsAsyncOperationBinding.class::isInstance) - .map(SnsAsyncOperationBinding.class::cast) - .findAny() - .map(this::mapToMessageBinding); - } - - private ProcessedMessageBinding mapToMessageBinding(SnsAsyncOperationBinding bindingAnnotation) { - return new ProcessedMessageBinding("sns", new SNSMessageBinding()); - } -} diff --git a/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/asyncapi/scanners/bindings/operations/SnsOperationBindingProcessor.java b/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/asyncapi/scanners/bindings/operations/SnsOperationBindingProcessor.java deleted file mode 100644 index 8bf25ca90..000000000 --- a/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/asyncapi/scanners/bindings/operations/SnsOperationBindingProcessor.java +++ /dev/null @@ -1,56 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.sns.asyncapi.scanners.bindings.operations; - -import io.github.springwolf.asyncapi.v3.bindings.sns.SNSOperationBinding; -import io.github.springwolf.asyncapi.v3.bindings.sns.SNSOperationBindingConsumer; -import io.github.springwolf.asyncapi.v3.bindings.sns.SNSOperationBindingIdentifier; -import io.github.springwolf.core.asyncapi.scanners.bindings.operations.AbstractOperationBindingProcessor; -import io.github.springwolf.core.asyncapi.scanners.bindings.operations.ProcessedOperationBinding; -import io.github.springwolf.plugins.sns.annotations.SnsAsyncOperationBinding; -import io.github.springwolf.plugins.sns.annotations.SnsAsyncOperationBindingIdentifier; - -import java.util.List; - -public class SnsOperationBindingProcessor extends AbstractOperationBindingProcessor { - - @Override - protected ProcessedOperationBinding mapToOperationBinding(SnsAsyncOperationBinding bindingAnnotation) { - var identifier = convertAnnotation(bindingAnnotation.endpoint()); - var protocol = readProtocol(bindingAnnotation.protocol()); - - var consumer = SNSOperationBindingConsumer.builder() - .protocol(protocol) - .endpoint(identifier) - .rawMessageDelivery(bindingAnnotation.rawMessageDelivery()) - .build(); - var snsOperationBinding = - SNSOperationBinding.builder().consumers(List.of(consumer)).build(); - return new ProcessedOperationBinding("sns", snsOperationBinding); - } - - private SNSOperationBindingConsumer.Protocol readProtocol(String protocol) { - return SNSOperationBindingConsumer.Protocol.valueOf(protocol.toUpperCase()); - } - - private SNSOperationBindingIdentifier convertAnnotation(SnsAsyncOperationBindingIdentifier identifier) { - var builder = SNSOperationBindingIdentifier.builder(); - - if (!identifier.url().isBlank()) { - builder.url(identifier.url()); - } - if (!identifier.arn().isBlank()) { - builder.arn(identifier.arn()); - } - if (!identifier.name().isBlank()) { - builder.name(identifier.name()); - } - if (!identifier.email().isBlank()) { - builder.email(identifier.email()); - } - if (!identifier.phone().isBlank()) { - builder.phone(identifier.phone()); - } - - return builder.build(); - } -} diff --git a/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/configuration/SpringwolfSnsAutoConfiguration.java b/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/configuration/SpringwolfSnsAutoConfiguration.java index 8f645709c..da8e8df46 100644 --- a/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/configuration/SpringwolfSnsAutoConfiguration.java +++ b/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/configuration/SpringwolfSnsAutoConfiguration.java @@ -12,7 +12,7 @@ * Autoconfiguration for the springwolf sns plugin. */ @AutoConfiguration -@Import({SpringwolfSnsScannerConfiguration.class, SpringwolfSnsProducerConfiguration.class}) +@Import({SpringwolfSnsProducerConfiguration.class}) @ConditionalOnProperty(name = SpringwolfConfigConstants.SPRINGWOLF_ENABLED, havingValue = "true", matchIfMissing = true) public class SpringwolfSnsAutoConfiguration { diff --git a/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/configuration/SpringwolfSnsScannerConfiguration.java b/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/configuration/SpringwolfSnsScannerConfiguration.java deleted file mode 100644 index b5c2c65cd..000000000 --- a/springwolf-plugins/springwolf-sns-plugin/src/main/java/io/github/springwolf/plugins/sns/configuration/SpringwolfSnsScannerConfiguration.java +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.sns.configuration; - -import io.github.springwolf.core.asyncapi.scanners.bindings.BindingProcessorPriority; -import io.github.springwolf.plugins.sns.asyncapi.scanners.bindings.messages.SnsMessageBindingProcessor; -import io.github.springwolf.plugins.sns.asyncapi.scanners.bindings.operations.SnsOperationBindingProcessor; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -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 - */ -@Configuration(proxyBeanMethods = false) -public class SpringwolfSnsScannerConfiguration { - - @Bean - @Order(value = BindingProcessorPriority.PROTOCOL_BINDING) - @ConditionalOnMissingBean - public SnsMessageBindingProcessor snsMessageBindingProcessor() { - return new SnsMessageBindingProcessor(); - } - - @Bean - @Order(value = BindingProcessorPriority.PROTOCOL_BINDING) - @ConditionalOnMissingBean - public SnsOperationBindingProcessor snsOperationBindingProcessor() { - return new SnsOperationBindingProcessor(); - } -} diff --git a/springwolf-plugins/springwolf-sns-plugin/src/test/java/io/github/springwolf/plugins/sns/asyncapi/scanners/bindings/messages/SnsMessageBindingProcessorTest.java b/springwolf-plugins/springwolf-sns-plugin/src/test/java/io/github/springwolf/plugins/sns/asyncapi/scanners/bindings/messages/SnsMessageBindingProcessorTest.java deleted file mode 100644 index 1a3cd78f7..000000000 --- a/springwolf-plugins/springwolf-sns-plugin/src/test/java/io/github/springwolf/plugins/sns/asyncapi/scanners/bindings/messages/SnsMessageBindingProcessorTest.java +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.sns.asyncapi.scanners.bindings.messages; - -import io.github.springwolf.asyncapi.v3.bindings.sns.SNSMessageBinding; -import io.github.springwolf.core.asyncapi.scanners.bindings.messages.ProcessedMessageBinding; -import io.github.springwolf.plugins.sns.annotations.SnsAsyncOperationBinding; -import io.github.springwolf.plugins.sns.annotations.SnsAsyncOperationBindingIdentifier; -import org.junit.jupiter.api.Test; - -import java.lang.reflect.Method; -import java.util.Optional; - -import static org.assertj.core.api.Assertions.assertThat; - -class SnsMessageBindingProcessorTest { - private final SnsMessageBindingProcessor processor = new SnsMessageBindingProcessor(); - - @Test - void processTest() throws NoSuchMethodException { - Method method = SnsMessageBindingProcessorTest.class.getMethod("methodWithAnnotation"); - - ProcessedMessageBinding binding = processor.process(method).get(); - - assertThat(binding.getType()).isEqualTo("sns"); - assertThat(binding.getBinding()).isEqualTo(new SNSMessageBinding()); - } - - @Test - void processWithoutAnnotationTest() throws NoSuchMethodException { - Method method = SnsMessageBindingProcessorTest.class.getMethod("methodWithoutAnnotation"); - - Optional binding = processor.process(method); - - assertThat(binding).isNotPresent(); - } - - @SnsAsyncOperationBinding(protocol = "sqs", endpoint = @SnsAsyncOperationBindingIdentifier()) - public void methodWithAnnotation() {} - - public void methodWithoutAnnotation() {} -} diff --git a/springwolf-plugins/springwolf-sns-plugin/src/test/java/io/github/springwolf/plugins/sns/asyncapi/scanners/bindings/operations/SnsOperationBindingProcessorTest.java b/springwolf-plugins/springwolf-sns-plugin/src/test/java/io/github/springwolf/plugins/sns/asyncapi/scanners/bindings/operations/SnsOperationBindingProcessorTest.java deleted file mode 100644 index bb8651956..000000000 --- a/springwolf-plugins/springwolf-sns-plugin/src/test/java/io/github/springwolf/plugins/sns/asyncapi/scanners/bindings/operations/SnsOperationBindingProcessorTest.java +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.sns.asyncapi.scanners.bindings.operations; - -import io.github.springwolf.asyncapi.v3.bindings.sns.SNSOperationBinding; -import io.github.springwolf.asyncapi.v3.bindings.sns.SNSOperationBindingConsumer; -import io.github.springwolf.asyncapi.v3.bindings.sns.SNSOperationBindingIdentifier; -import io.github.springwolf.core.asyncapi.scanners.bindings.operations.ProcessedOperationBinding; -import io.github.springwolf.plugins.sns.annotations.SnsAsyncOperationBinding; -import io.github.springwolf.plugins.sns.annotations.SnsAsyncOperationBindingIdentifier; -import org.junit.jupiter.api.Test; - -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; - -class SnsOperationBindingProcessorTest { - private final SnsOperationBindingProcessor processor = new SnsOperationBindingProcessor(); - - @Test - void mapToOperationBindingTest() throws NoSuchMethodException { - SnsAsyncOperationBinding annotation = SnsOperationBindingProcessorTest.class - .getMethod("methodWithAnnotation") - .getAnnotation(SnsAsyncOperationBinding.class); - - ProcessedOperationBinding binding = processor.mapToOperationBinding(annotation); - - var expectedOperation = SNSOperationBinding.builder() - .consumers(List.of(SNSOperationBindingConsumer.builder() - .protocol(SNSOperationBindingConsumer.Protocol.SQS) - .endpoint(SNSOperationBindingIdentifier.builder().build()) - .rawMessageDelivery(true) - .build())) - .build(); - - assertThat(binding.getType()).isEqualTo("sns"); - assertThat(binding.getBinding()).isEqualTo(expectedOperation); - } - - @SnsAsyncOperationBinding(protocol = "sqs", endpoint = @SnsAsyncOperationBindingIdentifier()) - public void methodWithAnnotation() {} -} diff --git a/springwolf-plugins/springwolf-sqs-plugin/build.gradle b/springwolf-plugins/springwolf-sqs-plugin/build.gradle index 526a5482a..04420b8b7 100644 --- a/springwolf-plugins/springwolf-sqs-plugin/build.gradle +++ b/springwolf-plugins/springwolf-sqs-plugin/build.gradle @@ -15,6 +15,7 @@ dependencyManagement { dependencies { api project(":springwolf-asyncapi") api project(":springwolf-core") + api project(":springwolf-bindings:springwolf-sqs-binding") implementation "org.slf4j:slf4j-api:${slf4jApiVersion}" diff --git a/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/annotations/SqsAsyncOperationBinding.java b/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/annotations/SqsAsyncOperationBinding.java deleted file mode 100644 index 94f4f7475..000000000 --- a/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/annotations/SqsAsyncOperationBinding.java +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.sqs.annotations; - -import io.github.springwolf.core.asyncapi.annotations.AsyncListener; -import io.github.springwolf.core.asyncapi.annotations.AsyncOperationBinding; -import io.github.springwolf.core.asyncapi.annotations.AsyncPublisher; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * {@code @SqsAsyncOperationBinding} is a method-level annotation used in combination with {@link AsyncPublisher} or {@link AsyncListener}. - * It configures the operation binding for the SQS protocol. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(value = {ElementType.METHOD, ElementType.ANNOTATION_TYPE}) -@AsyncOperationBinding -@Inherited -public @interface SqsAsyncOperationBinding { - - SqsAsyncQueueBinding[] queues() default {}; -} diff --git a/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/annotations/SqsAsyncQueueBinding.java b/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/annotations/SqsAsyncQueueBinding.java deleted file mode 100644 index 78dfb5454..000000000 --- a/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/annotations/SqsAsyncQueueBinding.java +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.sqs.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.PARAMETER}) -@Inherited -public @interface SqsAsyncQueueBinding { - - String name() default ""; - - boolean fifoQueue() default true; - - int deliveryDelay() default 0; -} diff --git a/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/asyncapi/scanners/bindings/messages/SqsMessageBindingProcessor.java b/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/asyncapi/scanners/bindings/messages/SqsMessageBindingProcessor.java deleted file mode 100644 index 75a1e18cc..000000000 --- a/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/asyncapi/scanners/bindings/messages/SqsMessageBindingProcessor.java +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.sqs.asyncapi.scanners.bindings.messages; - -import io.github.springwolf.asyncapi.v3.bindings.sqs.SQSMessageBinding; -import io.github.springwolf.core.asyncapi.scanners.bindings.messages.MessageBindingProcessor; -import io.github.springwolf.core.asyncapi.scanners.bindings.messages.ProcessedMessageBinding; -import io.github.springwolf.plugins.sqs.annotations.SqsAsyncOperationBinding; -import org.springframework.context.EmbeddedValueResolverAware; -import org.springframework.util.StringValueResolver; - -import java.lang.reflect.AnnotatedElement; -import java.util.Arrays; -import java.util.Optional; - -public class SqsMessageBindingProcessor implements MessageBindingProcessor, EmbeddedValueResolverAware { - private StringValueResolver resolver; - - @Override - public void setEmbeddedValueResolver(StringValueResolver resolver) { - this.resolver = resolver; - } - - @Override - public Optional process(AnnotatedElement annotatedElement) { - return Arrays.stream(annotatedElement.getAnnotations()) - .filter(SqsAsyncOperationBinding.class::isInstance) - .map(SqsAsyncOperationBinding.class::cast) - .findAny() - .map(this::mapToMessageBinding); - } - - private ProcessedMessageBinding mapToMessageBinding(SqsAsyncOperationBinding bindingAnnotation) { - SQSMessageBinding sqsMessageBinding = new SQSMessageBinding(); - - return new ProcessedMessageBinding("sqs", sqsMessageBinding); - } -} diff --git a/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/asyncapi/scanners/bindings/operations/SqsOperationBindingProcessor.java b/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/asyncapi/scanners/bindings/operations/SqsOperationBindingProcessor.java deleted file mode 100644 index 4a37ae819..000000000 --- a/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/asyncapi/scanners/bindings/operations/SqsOperationBindingProcessor.java +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.sqs.asyncapi.scanners.bindings.operations; - -import io.github.springwolf.asyncapi.v3.bindings.sqs.SQSChannelBindingQueue; -import io.github.springwolf.asyncapi.v3.bindings.sqs.SQSOperationBinding; -import io.github.springwolf.core.asyncapi.scanners.bindings.operations.AbstractOperationBindingProcessor; -import io.github.springwolf.core.asyncapi.scanners.bindings.operations.ProcessedOperationBinding; -import io.github.springwolf.plugins.sqs.annotations.SqsAsyncOperationBinding; -import io.github.springwolf.plugins.sqs.annotations.SqsAsyncQueueBinding; - -import java.util.ArrayList; -import java.util.List; - -public class SqsOperationBindingProcessor extends AbstractOperationBindingProcessor { - - @Override - protected ProcessedOperationBinding mapToOperationBinding(SqsAsyncOperationBinding bindingAnnotation) { - List queues = new ArrayList<>(); - for (SqsAsyncQueueBinding queue : bindingAnnotation.queues()) { - queues.add(SQSChannelBindingQueue.builder() - .name(queue.name()) - .fifoQueue(queue.fifoQueue()) - .build()); - } - var operationBinding = SQSOperationBinding.builder().queues(queues).build(); - return new ProcessedOperationBinding("sqs", operationBinding); - } -} diff --git a/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/configuration/SpringwolfSqsScannerConfiguration.java b/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/configuration/SpringwolfSqsScannerConfiguration.java index b80ae4ba9..fad10e9f1 100644 --- a/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/configuration/SpringwolfSqsScannerConfiguration.java +++ b/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/configuration/SpringwolfSqsScannerConfiguration.java @@ -13,9 +13,6 @@ import io.github.springwolf.core.asyncapi.scanners.operations.SpringAnnotationOperationsScanner; import io.github.springwolf.core.asyncapi.scanners.operations.annotations.SpringAnnotationMethodLevelOperationsScanner; import io.github.springwolf.plugins.sqs.asyncapi.scanners.bindings.SqsBindingFactory; -import io.github.springwolf.plugins.sqs.asyncapi.scanners.bindings.messages.SqsMessageBindingProcessor; -import io.github.springwolf.plugins.sqs.asyncapi.scanners.bindings.operations.SqsOperationBindingProcessor; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -72,18 +69,4 @@ public SpringAnnotationOperationsScanner simpleSqsMethodLevelListenerAnnotationO return new SpringAnnotationOperationsScanner(classScanner, strategy); } - - @Bean - @Order(value = BindingProcessorPriority.PROTOCOL_BINDING) - @ConditionalOnMissingBean - public SqsMessageBindingProcessor sqsMessageBindingProcessor() { - return new SqsMessageBindingProcessor(); - } - - @Bean - @Order(value = BindingProcessorPriority.PROTOCOL_BINDING) - @ConditionalOnMissingBean - public SqsOperationBindingProcessor sqsOperationBindingProcessor() { - return new SqsOperationBindingProcessor(); - } } diff --git a/springwolf-plugins/springwolf-sqs-plugin/src/test/java/io/github/springwolf/plugins/sqs/asyncapi/scanners/bindings/messages/SqsMessageBindingProcessorTest.java b/springwolf-plugins/springwolf-sqs-plugin/src/test/java/io/github/springwolf/plugins/sqs/asyncapi/scanners/bindings/messages/SqsMessageBindingProcessorTest.java deleted file mode 100644 index 388eb899e..000000000 --- a/springwolf-plugins/springwolf-sqs-plugin/src/test/java/io/github/springwolf/plugins/sqs/asyncapi/scanners/bindings/messages/SqsMessageBindingProcessorTest.java +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.sqs.asyncapi.scanners.bindings.messages; - -import io.github.springwolf.asyncapi.v3.bindings.sqs.SQSMessageBinding; -import io.github.springwolf.core.asyncapi.scanners.bindings.messages.ProcessedMessageBinding; -import io.github.springwolf.plugins.sqs.annotations.SqsAsyncOperationBinding; -import org.junit.jupiter.api.Test; - -import java.lang.reflect.Method; -import java.util.Optional; - -import static org.assertj.core.api.Assertions.assertThat; - -class SqsMessageBindingProcessorTest { - private final SqsMessageBindingProcessor processor = new SqsMessageBindingProcessor(); - - @Test - void processTest() throws NoSuchMethodException { - Method method = SqsMessageBindingProcessorTest.class.getMethod("methodWithAnnotation"); - - ProcessedMessageBinding binding = processor.process(method).get(); - - assertThat(binding.getType()).isEqualTo("sqs"); - assertThat(binding.getBinding()).isEqualTo(new SQSMessageBinding()); - } - - @Test - void processWithoutAnnotationTest() throws NoSuchMethodException { - Method method = SqsMessageBindingProcessorTest.class.getMethod("methodWithoutAnnotation"); - - Optional binding = processor.process(method); - - assertThat(binding).isNotPresent(); - } - - @SqsAsyncOperationBinding - public void methodWithAnnotation() {} - - public void methodWithoutAnnotation() {} -} diff --git a/springwolf-plugins/springwolf-sqs-plugin/src/test/java/io/github/springwolf/plugins/sqs/asyncapi/scanners/bindings/operations/SqsOperationBindingProcessorTest.java b/springwolf-plugins/springwolf-sqs-plugin/src/test/java/io/github/springwolf/plugins/sqs/asyncapi/scanners/bindings/operations/SqsOperationBindingProcessorTest.java deleted file mode 100644 index 6e6de868f..000000000 --- a/springwolf-plugins/springwolf-sqs-plugin/src/test/java/io/github/springwolf/plugins/sqs/asyncapi/scanners/bindings/operations/SqsOperationBindingProcessorTest.java +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -package io.github.springwolf.plugins.sqs.asyncapi.scanners.bindings.operations; - -import io.github.springwolf.asyncapi.v3.bindings.sqs.SQSChannelBindingQueue; -import io.github.springwolf.asyncapi.v3.bindings.sqs.SQSOperationBinding; -import io.github.springwolf.core.asyncapi.scanners.bindings.operations.ProcessedOperationBinding; -import io.github.springwolf.plugins.sqs.annotations.SqsAsyncOperationBinding; -import io.github.springwolf.plugins.sqs.annotations.SqsAsyncQueueBinding; -import org.junit.jupiter.api.Test; - -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; - -class SqsOperationBindingProcessorTest { - private final SqsOperationBindingProcessor processor = new SqsOperationBindingProcessor(); - - @Test - void mapToOperationBindingTest() throws NoSuchMethodException { - SqsAsyncOperationBinding annotation = SqsOperationBindingProcessorTest.class - .getMethod("methodWithAnnotation") - .getAnnotation(SqsAsyncOperationBinding.class); - - ProcessedOperationBinding binding = processor.mapToOperationBinding(annotation); - - var expectedOperation = SQSOperationBinding.builder() - .queues(List.of(SQSChannelBindingQueue.builder() - .name("queue-name") - .fifoQueue(true) - .build())) - .build(); - - assertThat(binding.getType()).isEqualTo("sqs"); - assertThat(binding.getBinding()).isEqualTo(expectedOperation); - } - - @SqsAsyncOperationBinding(queues = {@SqsAsyncQueueBinding(name = "queue-name")}) - public void methodWithAnnotation() {} -} From ec4d818d9e51c893f15787167e53fc99dc5ae493 Mon Sep 17 00:00:00 2001 From: Timon Back Date: Sun, 28 Apr 2024 17:46:27 +0200 Subject: [PATCH 6/7] chore: update dependency configuration --- springwolf-examples/springwolf-amqp-example/build.gradle | 2 ++ springwolf-examples/springwolf-jms-example/build.gradle | 2 ++ springwolf-examples/springwolf-kafka-example/build.gradle | 2 ++ springwolf-examples/springwolf-sns-example/build.gradle | 2 ++ springwolf-examples/springwolf-sqs-example/build.gradle | 2 ++ springwolf-plugins/springwolf-amqp-plugin/build.gradle | 1 + springwolf-plugins/springwolf-jms-plugin/build.gradle | 1 + springwolf-plugins/springwolf-kafka-plugin/build.gradle | 1 + springwolf-plugins/springwolf-sns-plugin/build.gradle | 2 +- springwolf-plugins/springwolf-sqs-plugin/build.gradle | 1 + 10 files changed, 15 insertions(+), 1 deletion(-) diff --git a/springwolf-examples/springwolf-amqp-example/build.gradle b/springwolf-examples/springwolf-amqp-example/build.gradle index deab1538a..0782e7db2 100644 --- a/springwolf-examples/springwolf-amqp-example/build.gradle +++ b/springwolf-examples/springwolf-amqp-example/build.gradle @@ -11,6 +11,8 @@ plugins { dependencies { implementation project(":springwolf-core") implementation project(":springwolf-plugins:springwolf-amqp") + permitUnusedDeclared project(":springwolf-plugins:springwolf-amqp") + permitUsedUndeclared project(":springwolf-bindings:springwolf-amqp-binding") annotationProcessor project(":springwolf-plugins:springwolf-amqp") runtimeOnly project(":springwolf-ui") diff --git a/springwolf-examples/springwolf-jms-example/build.gradle b/springwolf-examples/springwolf-jms-example/build.gradle index 2c5117dc6..e761f9284 100644 --- a/springwolf-examples/springwolf-jms-example/build.gradle +++ b/springwolf-examples/springwolf-jms-example/build.gradle @@ -12,6 +12,8 @@ dependencies { implementation project(":springwolf-core") implementation project(":springwolf-add-ons:springwolf-generic-binding") implementation project(":springwolf-plugins:springwolf-jms") + permitUnusedDeclared project(":springwolf-plugins:springwolf-jms") + permitUsedUndeclared project(":springwolf-bindings:springwolf-jms-binding") annotationProcessor project(":springwolf-plugins:springwolf-jms") runtimeOnly project(":springwolf-ui") diff --git a/springwolf-examples/springwolf-kafka-example/build.gradle b/springwolf-examples/springwolf-kafka-example/build.gradle index 16402d438..b6eae2fc0 100644 --- a/springwolf-examples/springwolf-kafka-example/build.gradle +++ b/springwolf-examples/springwolf-kafka-example/build.gradle @@ -15,6 +15,8 @@ plugins { dependencies { implementation project(":springwolf-core") implementation project(":springwolf-plugins:springwolf-kafka") + permitUnusedDeclared project(":springwolf-plugins:springwolf-kafka") + permitUsedUndeclared project(":springwolf-bindings:springwolf-kafka-binding") runtimeOnly project(":springwolf-add-ons:springwolf-common-model-converters") runtimeOnly project(":springwolf-add-ons:springwolf-json-schema") diff --git a/springwolf-examples/springwolf-sns-example/build.gradle b/springwolf-examples/springwolf-sns-example/build.gradle index 6a09a4f84..71435af31 100644 --- a/springwolf-examples/springwolf-sns-example/build.gradle +++ b/springwolf-examples/springwolf-sns-example/build.gradle @@ -17,6 +17,8 @@ dependencyManagement { dependencies { implementation project(":springwolf-core") implementation project(":springwolf-plugins:springwolf-sns") + permitUnusedDeclared project(":springwolf-plugins:springwolf-sns") + permitUsedUndeclared project(":springwolf-bindings:springwolf-sns-binding") annotationProcessor project(":springwolf-plugins:springwolf-sns") runtimeOnly project(":springwolf-add-ons:springwolf-json-schema") diff --git a/springwolf-examples/springwolf-sqs-example/build.gradle b/springwolf-examples/springwolf-sqs-example/build.gradle index 3cf07786b..fb79385cc 100644 --- a/springwolf-examples/springwolf-sqs-example/build.gradle +++ b/springwolf-examples/springwolf-sqs-example/build.gradle @@ -17,6 +17,8 @@ dependencyManagement { dependencies { implementation project(":springwolf-core") implementation project(":springwolf-plugins:springwolf-sqs") + permitUnusedDeclared project(":springwolf-plugins:springwolf-sqs") + permitUsedUndeclared project(":springwolf-bindings:springwolf-sqs-binding") annotationProcessor project(":springwolf-plugins:springwolf-sqs") runtimeOnly project(":springwolf-ui") diff --git a/springwolf-plugins/springwolf-amqp-plugin/build.gradle b/springwolf-plugins/springwolf-amqp-plugin/build.gradle index 77817efa9..4fd189c84 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/build.gradle +++ b/springwolf-plugins/springwolf-amqp-plugin/build.gradle @@ -10,6 +10,7 @@ dependencies { api project(":springwolf-core") api project(":springwolf-asyncapi") api project(":springwolf-bindings:springwolf-amqp-binding") + permitUnusedDeclared project(":springwolf-bindings:springwolf-amqp-binding") implementation "org.slf4j:slf4j-api:${slf4jApiVersion}" diff --git a/springwolf-plugins/springwolf-jms-plugin/build.gradle b/springwolf-plugins/springwolf-jms-plugin/build.gradle index ab3284379..2505419c6 100644 --- a/springwolf-plugins/springwolf-jms-plugin/build.gradle +++ b/springwolf-plugins/springwolf-jms-plugin/build.gradle @@ -10,6 +10,7 @@ dependencies { api project(":springwolf-asyncapi") api project(":springwolf-core") api project(":springwolf-bindings:springwolf-jms-binding") + permitUnusedDeclared project(":springwolf-bindings:springwolf-jms-binding") implementation "jakarta.jms:jakarta.jms-api" diff --git a/springwolf-plugins/springwolf-kafka-plugin/build.gradle b/springwolf-plugins/springwolf-kafka-plugin/build.gradle index 79c3517f5..794b43623 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/build.gradle +++ b/springwolf-plugins/springwolf-kafka-plugin/build.gradle @@ -10,6 +10,7 @@ dependencies { api project(":springwolf-asyncapi") api project(":springwolf-core") api project(":springwolf-bindings:springwolf-kafka-binding") + permitUnusedDeclared project(":springwolf-bindings:springwolf-kafka-binding") implementation "io.swagger.core.v3:swagger-models-jakarta:${swaggerVersion}" permitUnusedDeclared "io.swagger.core.v3:swagger-models-jakarta:${swaggerVersion}" diff --git a/springwolf-plugins/springwolf-sns-plugin/build.gradle b/springwolf-plugins/springwolf-sns-plugin/build.gradle index 82ca77c11..6714190f2 100644 --- a/springwolf-plugins/springwolf-sns-plugin/build.gradle +++ b/springwolf-plugins/springwolf-sns-plugin/build.gradle @@ -13,9 +13,9 @@ dependencyManagement { } dependencies { - api project(":springwolf-asyncapi") api project(":springwolf-core") api project(":springwolf-bindings:springwolf-sns-binding") + permitUnusedDeclared project(":springwolf-bindings:springwolf-sns-binding") implementation "org.slf4j:slf4j-api:${slf4jApiVersion}" diff --git a/springwolf-plugins/springwolf-sqs-plugin/build.gradle b/springwolf-plugins/springwolf-sqs-plugin/build.gradle index 04420b8b7..c8441d4ee 100644 --- a/springwolf-plugins/springwolf-sqs-plugin/build.gradle +++ b/springwolf-plugins/springwolf-sqs-plugin/build.gradle @@ -16,6 +16,7 @@ dependencies { api project(":springwolf-asyncapi") api project(":springwolf-core") api project(":springwolf-bindings:springwolf-sqs-binding") + permitUnusedDeclared project(":springwolf-bindings:springwolf-sqs-binding") implementation "org.slf4j:slf4j-api:${slf4jApiVersion}" From 60f4d0a2f2a296e86f80d6bb65dd240ee913295f Mon Sep 17 00:00:00 2001 From: Timon Back Date: Fri, 31 May 2024 16:18:41 +0200 Subject: [PATCH 7/7] chore: detekt after rebase --- .../amqp/configuration/SpringwolfAmqpScannerConfiguration.java | 2 -- .../jms/configuration/SpringwolfJmsScannerConfiguration.java | 1 - .../configuration/SpringwolfKafkaScannerConfiguration.java | 3 --- .../sqs/configuration/SpringwolfSqsScannerConfiguration.java | 1 - 4 files changed, 7 deletions(-) diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/configuration/SpringwolfAmqpScannerConfiguration.java b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/configuration/SpringwolfAmqpScannerConfiguration.java index 307e8027c..7d1acebb6 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/configuration/SpringwolfAmqpScannerConfiguration.java +++ b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/configuration/SpringwolfAmqpScannerConfiguration.java @@ -12,8 +12,6 @@ import io.github.springwolf.core.asyncapi.scanners.operations.annotations.SpringAnnotationClassLevelOperationsScanner; import io.github.springwolf.core.asyncapi.scanners.operations.annotations.SpringAnnotationMethodLevelOperationsScanner; import io.github.springwolf.plugins.amqp.asyncapi.scanners.bindings.AmqpBindingFactory; -import io.github.springwolf.plugins.amqp.asyncapi.scanners.bindings.messages.AmqpMessageBindingProcessor; -import io.github.springwolf.plugins.amqp.asyncapi.scanners.bindings.operations.AmqpOperationBindingProcessor; import io.github.springwolf.plugins.amqp.asyncapi.scanners.common.headers.AsyncHeadersForAmqpBuilder; import org.springframework.amqp.core.Binding; import org.springframework.amqp.core.Exchange; diff --git a/springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/configuration/SpringwolfJmsScannerConfiguration.java b/springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/configuration/SpringwolfJmsScannerConfiguration.java index edbf54f54..b69e10c92 100644 --- a/springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/configuration/SpringwolfJmsScannerConfiguration.java +++ b/springwolf-plugins/springwolf-jms-plugin/src/main/java/io/github/springwolf/plugins/jms/configuration/SpringwolfJmsScannerConfiguration.java @@ -2,7 +2,6 @@ package io.github.springwolf.plugins.jms.configuration; import io.github.springwolf.core.asyncapi.components.ComponentsService; -import io.github.springwolf.core.asyncapi.scanners.bindings.BindingProcessorPriority; import io.github.springwolf.core.asyncapi.scanners.channels.ChannelPriority; import io.github.springwolf.core.asyncapi.scanners.channels.SpringAnnotationChannelsScanner; import io.github.springwolf.core.asyncapi.scanners.channels.annotations.SpringAnnotationMethodLevelChannelsScanner; diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/configuration/SpringwolfKafkaScannerConfiguration.java b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/configuration/SpringwolfKafkaScannerConfiguration.java index 14c748169..f6ebeea0b 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/configuration/SpringwolfKafkaScannerConfiguration.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/configuration/SpringwolfKafkaScannerConfiguration.java @@ -12,10 +12,7 @@ import io.github.springwolf.core.asyncapi.scanners.operations.annotations.SpringAnnotationClassLevelOperationsScanner; import io.github.springwolf.core.asyncapi.scanners.operations.annotations.SpringAnnotationMethodLevelOperationsScanner; import io.github.springwolf.plugins.kafka.asyncapi.scanners.bindings.KafkaBindingFactory; -import io.github.springwolf.plugins.kafka.asyncapi.scanners.bindings.messages.KafkaMessageBindingProcessor; -import io.github.springwolf.plugins.kafka.asyncapi.scanners.bindings.operations.KafkaOperationBindingProcessor; import io.github.springwolf.plugins.kafka.asyncapi.scanners.common.header.AsyncHeadersForKafkaBuilder; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/configuration/SpringwolfSqsScannerConfiguration.java b/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/configuration/SpringwolfSqsScannerConfiguration.java index fad10e9f1..82dcb8c66 100644 --- a/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/configuration/SpringwolfSqsScannerConfiguration.java +++ b/springwolf-plugins/springwolf-sqs-plugin/src/main/java/io/github/springwolf/plugins/sqs/configuration/SpringwolfSqsScannerConfiguration.java @@ -3,7 +3,6 @@ import io.awspring.cloud.sqs.annotation.SqsListener; import io.github.springwolf.core.asyncapi.components.ComponentsService; -import io.github.springwolf.core.asyncapi.scanners.bindings.BindingProcessorPriority; import io.github.springwolf.core.asyncapi.scanners.channels.ChannelPriority; import io.github.springwolf.core.asyncapi.scanners.channels.SpringAnnotationChannelsScanner; import io.github.springwolf.core.asyncapi.scanners.channels.annotations.SpringAnnotationMethodLevelChannelsScanner;