Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add jms bindings artifact * feat: add amqp bindings artifact * feat: add kafka bindings artifact * chore: update bindings dependencies * docs: update README.md bindings
- Loading branch information
Showing
28 changed files
with
803 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
plugins { | ||
id 'java-library' | ||
|
||
id 'org.springframework.boot' | ||
id 'io.spring.dependency-management' | ||
id 'ca.cutterslade.analyze' | ||
} | ||
|
||
dependencies { | ||
api project(":springwolf-asyncapi") | ||
api project(":springwolf-core") | ||
|
||
implementation "org.springframework:spring-context" | ||
implementation "org.springframework:spring-core" | ||
implementation "org.springframework.boot:spring-boot-autoconfigure" | ||
|
||
testImplementation "org.assertj:assertj-core:${assertjCoreVersion}" | ||
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" | ||
|
||
testRuntimeOnly "org.junit.jupiter:junit-jupiter:${junitJupiterVersion}" | ||
} | ||
|
||
jar { | ||
enabled = true | ||
archiveClassifier = '' | ||
} | ||
bootJar.enabled = false | ||
|
||
java { | ||
withJavadocJar() | ||
withSourcesJar() | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
pom { | ||
name = 'springwolf-amqp-binding' | ||
description = 'Automated JSON API documentation for AMQP Bindings' | ||
} | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...c/main/java/io/github/springwolf/bindings/amqp/annotations/AmqpAsyncOperationBinding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.springwolf.bindings.amqp.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; | ||
} |
34 changes: 34 additions & 0 deletions
34
...github/springwolf/bindings/amqp/configuration/SpringwolfAmqpBindingAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.springwolf.bindings.amqp.configuration; | ||
|
||
import io.github.springwolf.bindings.amqp.scanners.messages.AmqpMessageBindingProcessor; | ||
import io.github.springwolf.bindings.amqp.scanners.operations.AmqpOperationBindingProcessor; | ||
import io.github.springwolf.core.asyncapi.scanners.bindings.BindingProcessorPriority; | ||
import io.github.springwolf.core.configuration.properties.SpringwolfConfigConstants; | ||
import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.core.annotation.Order; | ||
|
||
/** | ||
* Autoconfiguration for the springwolf Amqp Binding. | ||
*/ | ||
@AutoConfiguration | ||
@ConditionalOnProperty(name = SpringwolfConfigConstants.SPRINGWOLF_ENABLED, havingValue = "true", matchIfMissing = true) | ||
public class SpringwolfAmqpBindingAutoConfiguration { | ||
|
||
@Bean | ||
@Order(value = BindingProcessorPriority.PROTOCOL_BINDING) | ||
@ConditionalOnMissingBean | ||
public AmqpOperationBindingProcessor amqpOperationBindingProcessor() { | ||
return new AmqpOperationBindingProcessor(); | ||
} | ||
|
||
@Bean | ||
@Order(value = BindingProcessorPriority.PROTOCOL_BINDING) | ||
@ConditionalOnMissingBean | ||
public AmqpMessageBindingProcessor amqpMessageBindingProcessor() { | ||
return new AmqpMessageBindingProcessor(); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...ava/io/github/springwolf/bindings/amqp/scanners/messages/AmqpMessageBindingProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.springwolf.bindings.amqp.scanners.messages; | ||
|
||
import io.github.springwolf.asyncapi.v3.bindings.amqp.AMQPMessageBinding; | ||
import io.github.springwolf.bindings.amqp.annotations.AmqpAsyncOperationBinding; | ||
import io.github.springwolf.core.asyncapi.scanners.bindings.messages.MessageBindingProcessor; | ||
import io.github.springwolf.core.asyncapi.scanners.bindings.messages.ProcessedMessageBinding; | ||
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<ProcessedMessageBinding> 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); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...io/github/springwolf/bindings/amqp/scanners/operations/AmqpOperationBindingProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.springwolf.bindings.amqp.scanners.operations; | ||
|
||
import io.github.springwolf.asyncapi.v3.bindings.amqp.AMQPOperationBinding; | ||
import io.github.springwolf.bindings.amqp.annotations.AmqpAsyncOperationBinding; | ||
import io.github.springwolf.core.asyncapi.scanners.bindings.operations.AbstractOperationBindingProcessor; | ||
import io.github.springwolf.core.asyncapi.scanners.bindings.operations.ProcessedOperationBinding; | ||
|
||
import java.util.Arrays; | ||
|
||
public class AmqpOperationBindingProcessor extends AbstractOperationBindingProcessor<AmqpAsyncOperationBinding> { | ||
@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); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
io.github.springwolf.bindings.amqp.configuration.SpringwolfAmqpBindingAutoConfiguration |
40 changes: 40 additions & 0 deletions
40
...io/github/springwolf/bindings/amqp/scanners/messages/AmqpMessageBindingProcessorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.springwolf.bindings.amqp.scanners.messages; | ||
|
||
import io.github.springwolf.asyncapi.v3.bindings.amqp.AMQPMessageBinding; | ||
import io.github.springwolf.bindings.amqp.annotations.AmqpAsyncOperationBinding; | ||
import io.github.springwolf.core.asyncapi.scanners.bindings.messages.ProcessedMessageBinding; | ||
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<ProcessedMessageBinding> binding = processor.process(method); | ||
|
||
assertThat(binding).isNotPresent(); | ||
} | ||
|
||
@AmqpAsyncOperationBinding | ||
public void methodWithAnnotation() {} | ||
|
||
public void methodWithoutAnnotation() {} | ||
} |
38 changes: 38 additions & 0 deletions
38
...ithub/springwolf/bindings/amqp/scanners/operations/AmqpOperationBindingProcessorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.springwolf.bindings.amqp.scanners.operations; | ||
|
||
import io.github.springwolf.asyncapi.v3.bindings.amqp.AMQPOperationBinding; | ||
import io.github.springwolf.bindings.amqp.annotations.AmqpAsyncOperationBinding; | ||
import io.github.springwolf.core.asyncapi.scanners.bindings.operations.ProcessedOperationBinding; | ||
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() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
plugins { | ||
id 'java-library' | ||
|
||
id 'org.springframework.boot' | ||
id 'io.spring.dependency-management' | ||
id 'ca.cutterslade.analyze' | ||
} | ||
|
||
dependencies { | ||
api project(":springwolf-asyncapi") | ||
api project(":springwolf-core") | ||
|
||
implementation "org.springframework:spring-context" | ||
implementation "org.springframework:spring-core" | ||
implementation "org.springframework.boot:spring-boot-autoconfigure" | ||
|
||
testImplementation "org.assertj:assertj-core:${assertjCoreVersion}" | ||
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" | ||
|
||
testRuntimeOnly "org.junit.jupiter:junit-jupiter:${junitJupiterVersion}" | ||
} | ||
|
||
jar { | ||
enabled = true | ||
archiveClassifier = '' | ||
} | ||
bootJar.enabled = false | ||
|
||
java { | ||
withJavadocJar() | ||
withSourcesJar() | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
pom { | ||
name = 'springwolf-jms-binding' | ||
description = 'Automated JSON API documentation for JMS Bindings' | ||
} | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...src/main/java/io/github/springwolf/bindings/jms/annotations/JmsAsyncOperationBinding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.springwolf.bindings.jms.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 {} |
Oops, something went wrong.