From c577d3ef2c06f80127e6854302c5ee6c0b814db6 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Sun, 5 Oct 2008 20:14:42 +0000 Subject: [PATCH] MessagingAnnotationPostProcessor now only calls method-annotation postProcessors if the annotated Method should trigger the creation of a MessageEndpoint. To qualify, it must be either a @ChannelAdapter annotation or define an "inputChannel". --- .../MessagingAnnotationPostProcessor.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessor.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessor.java index ac965ecaee..96059e07b8 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessor.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessor.java @@ -46,6 +46,7 @@ import org.springframework.stereotype.Component; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.ReflectionUtils; +import org.springframework.util.StringUtils; /** * A {@link BeanPostProcessor} implementation that processes method-level @@ -105,6 +106,9 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Bean for (Annotation annotation : annotations) { MethodAnnotationPostProcessor postProcessor = postProcessors.get(annotation.annotationType()); if (postProcessor != null) { + if (!shouldCreateEndpoint(annotation)) { + continue; + } Object result = postProcessor.postProcess(bean, beanName, method, annotation); if (result != null && result instanceof MessageEndpoint) { String endpointBeanName = generateBeanName(beanName, method, annotation.annotationType()); @@ -123,6 +127,15 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Bean return bean; } + private boolean shouldCreateEndpoint(Annotation annotation) { + if (annotation instanceof ChannelAdapter) { + return true; + } + Object inputChannel = AnnotationUtils.getValue(annotation, "inputChannel"); + return (inputChannel != null && inputChannel instanceof String + && StringUtils.hasText((String) inputChannel)); + } + private Class getBeanClass(Object bean) { Class targetClass = AopUtils.getTargetClass(bean); return (targetClass != null) ? targetClass : bean.getClass();