-
-
Notifications
You must be signed in to change notification settings - Fork 344
Add SqsListenerFilter for use by the annotation processor #1416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,10 @@ | |
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.springframework.messaging.converter.MessageConverter; | ||
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver; | ||
|
||
|
@@ -44,12 +47,23 @@ public class SqsListenerAnnotationBeanPostProcessor extends AbstractListenerAnno | |
|
||
private static final String GENERATED_ID_PREFIX = "io.awspring.cloud.sqs.sqsListenerEndpointContainer#"; | ||
|
||
private final List<SqsListenerFilter> filters; | ||
|
||
public SqsListenerAnnotationBeanPostProcessor(Optional<List<SqsListenerFilter>> filters) { | ||
this.filters = filters.orElseGet(Collections::emptyList); | ||
} | ||
|
||
@Override | ||
protected Class<SqsListener> getAnnotationClass() { | ||
return SqsListener.class; | ||
} | ||
|
||
@Override | ||
protected Endpoint createEndpoint(SqsListener sqsListenerAnnotation) { | ||
if (filters.stream().anyMatch(f -> !f.createEndpoint(sqsListenerAnnotation))) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this logic would be better placed in the |
||
return null; | ||
} | ||
|
||
return SqsEndpoint.builder().queueNames(resolveEndpointNames(sqsListenerAnnotation.value())) | ||
.factoryBeanName(resolveAsString(sqsListenerAnnotation.factory(), "factory")) | ||
.id(getEndpointId(sqsListenerAnnotation.id())) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.awspring.cloud.sqs.annotation; | ||
|
||
/** | ||
* Predicate interface to filter {@link SqsListener} annotations during bean post-processing. | ||
*/ | ||
@FunctionalInterface | ||
public interface SqsListenerFilter { | ||
|
||
boolean createEndpoint(SqsListener annotation); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not filter the endpoints here, before the
map
method?