Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Mautsch committed Jul 6, 2024
1 parent 6fa53e5 commit a42e656
Showing 1 changed file with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,15 @@ public NatsListenerAspect(NatsSubscription natsSubscription, ApplicationContext

@PostConstruct
public void init() {
String[] beanNames = applicationContext.getBeanDefinitionNames();
for (String beanName : beanNames) {
if (!beanName.equals("natsListenerAspect")) {
Object bean = applicationContext.getBean(beanName);
Arrays.stream(AopUtils.getTargetClass(bean).getDeclaredMethods())
.filter(method -> method.isAnnotationPresent(NatsListener.class))
.forEach(method -> {
NatsListener natsListener = method.getAnnotation(NatsListener.class);
setupSubscription(bean, method, natsListener);
});
}
}
Arrays.stream(applicationContext.getBeanDefinitionNames())
.filter(beanName -> !beanName.equals("natsListenerAspect"))
.forEach(beanName -> {
var bean = applicationContext.getBean(beanName);
Arrays.stream(AopUtils.getTargetClass(bean).getDeclaredMethods())
.filter(method -> method.isAnnotationPresent(NatsListener.class))
.forEach(method -> setupSubscription(bean, method, method.getAnnotation(NatsListener.class)));
});

}

private void setupSubscription(Object bean, Method method, NatsListener natsListener) {
Expand Down

0 comments on commit a42e656

Please sign in to comment.