From 2c9e93a90715c54d9e22a589713d3e996395abb9 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Mon, 10 Dec 2007 06:58:59 +0000 Subject: [PATCH] renamed ChannelResolver to ChannelMapping --- ...ationAwareMessagePublishingInterceptor.java | 12 ++++++------ .../aop/PublisherAnnotationAdvisor.java | 12 ++++++------ .../aop/PublisherAnnotationPostProcessor.java | 16 ++++++++-------- .../integration/bus/MessageBus.java | 8 ++++---- ...hannelResolver.java => ChannelMapping.java} | 4 ++-- .../endpoint/GenericMessageEndpoint.java | 18 +++++++++--------- .../integration/endpoint/MessageEndpoint.java | 4 ++-- .../aop/PublisherAnnotationAdvisorTests.java | 14 +++++++------- .../publisherAnnotationPostProcessorTests.xml | 2 +- .../endpoint/GenericMessageEndpointTests.java | 10 ---------- 10 files changed, 45 insertions(+), 55 deletions(-) rename spring-eai-core/src/main/java/org/springframework/integration/channel/{ChannelResolver.java => ChannelMapping.java} (90%) diff --git a/spring-eai-core/src/main/java/org/springframework/integration/aop/AnnotationAwareMessagePublishingInterceptor.java b/spring-eai-core/src/main/java/org/springframework/integration/aop/AnnotationAwareMessagePublishingInterceptor.java index 1e73a80f19..b00eb024d6 100644 --- a/spring-eai-core/src/main/java/org/springframework/integration/aop/AnnotationAwareMessagePublishingInterceptor.java +++ b/spring-eai-core/src/main/java/org/springframework/integration/aop/AnnotationAwareMessagePublishingInterceptor.java @@ -23,7 +23,7 @@ import org.aopalliance.intercept.MethodInvocation; import org.springframework.aop.support.AopUtils; import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.integration.channel.ChannelResolver; +import org.springframework.integration.channel.ChannelMapping; import org.springframework.integration.channel.MessageChannel; import org.springframework.util.Assert; @@ -39,17 +39,17 @@ public class AnnotationAwareMessagePublishingInterceptor extends MessagePublishi private String channelAttributeName; - private ChannelResolver channelResolver; + private ChannelMapping channelMapping; public AnnotationAwareMessagePublishingInterceptor(Class publisherAnnotationType, - String channelAttributeName, ChannelResolver channelResolver) { + String channelAttributeName, ChannelMapping channelMapping) { Assert.notNull(publisherAnnotationType, "publisherAnnotationType must not be null"); Assert.notNull(channelAttributeName, "channelAttributeName must not be null"); - Assert.notNull(channelResolver, "channelResolver must not be null"); + Assert.notNull(channelMapping, "channelMapping must not be null"); this.publisherAnnotationType = publisherAnnotationType; this.channelAttributeName = channelAttributeName; - this.channelResolver = channelResolver; + this.channelMapping = channelMapping; } @@ -61,7 +61,7 @@ public class AnnotationAwareMessagePublishingInterceptor extends MessagePublishi if (annotation != null) { String channelName = (String) AnnotationUtils.getValue(annotation, this.channelAttributeName); if (channelName != null) { - MessageChannel channel = this.channelResolver.resolve(channelName); + MessageChannel channel = this.channelMapping.getChannel(channelName); if (channel != null) { return channel; } diff --git a/spring-eai-core/src/main/java/org/springframework/integration/aop/PublisherAnnotationAdvisor.java b/spring-eai-core/src/main/java/org/springframework/integration/aop/PublisherAnnotationAdvisor.java index 0a890a588f..8d2323bee9 100644 --- a/spring-eai-core/src/main/java/org/springframework/integration/aop/PublisherAnnotationAdvisor.java +++ b/spring-eai-core/src/main/java/org/springframework/integration/aop/PublisherAnnotationAdvisor.java @@ -24,7 +24,7 @@ import org.springframework.aop.Pointcut; import org.springframework.aop.support.AbstractPointcutAdvisor; import org.springframework.aop.support.annotation.AnnotationMatchingPointcut; import org.springframework.integration.annotation.Publisher; -import org.springframework.integration.channel.ChannelResolver; +import org.springframework.integration.channel.ChannelMapping; import org.springframework.util.Assert; /** @@ -43,18 +43,18 @@ public class PublisherAnnotationAdvisor extends AbstractPointcutAdvisor { private AnnotationMatchingPointcut pointcut; - public PublisherAnnotationAdvisor(ChannelResolver channelResolver) { - this(Publisher.class, "channel", channelResolver); + public PublisherAnnotationAdvisor(ChannelMapping channelMapping) { + this(Publisher.class, "channel", channelMapping); } public PublisherAnnotationAdvisor(Class publisherAnnotationType, String channelNameAttribute, - ChannelResolver channelResolver) { + ChannelMapping channelMapping) { Assert.notNull(publisherAnnotationType, "publisherAnnotationType must not be null"); Assert.notNull(channelNameAttribute, "channelNameAttribute must not be null"); - Assert.notNull(channelResolver, "channelResolver must not be null"); + Assert.notNull(channelMapping, "channelMapping must not be null"); this.pointcut = AnnotationMatchingPointcut.forMethodAnnotation(publisherAnnotationType); this.advice = new AnnotationAwareMessagePublishingInterceptor(publisherAnnotationType, channelNameAttribute, - channelResolver); + channelMapping); } diff --git a/spring-eai-core/src/main/java/org/springframework/integration/aop/PublisherAnnotationPostProcessor.java b/spring-eai-core/src/main/java/org/springframework/integration/aop/PublisherAnnotationPostProcessor.java index 467dccfda1..b2130efcbe 100644 --- a/spring-eai-core/src/main/java/org/springframework/integration/aop/PublisherAnnotationPostProcessor.java +++ b/spring-eai-core/src/main/java/org/springframework/integration/aop/PublisherAnnotationPostProcessor.java @@ -26,7 +26,7 @@ import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.integration.annotation.Publisher; -import org.springframework.integration.channel.ChannelResolver; +import org.springframework.integration.channel.ChannelMapping; import org.springframework.util.Assert; /** @@ -41,7 +41,7 @@ public class PublisherAnnotationPostProcessor implements BeanPostProcessor, Bean private String channelNameAttribute = "channel"; - private ChannelResolver channelResolver; + private ChannelMapping channelMapping; private Advisor advisor; @@ -62,17 +62,17 @@ public class PublisherAnnotationPostProcessor implements BeanPostProcessor, Bean this.channelNameAttribute = channelNameAttribute; } - public void setChannelResolver(ChannelResolver channelResolver) { - Assert.notNull(channelResolver, "channelResolver must not be null"); - this.channelResolver = channelResolver; + public void setChannelMapping(ChannelMapping channelMapping) { + Assert.notNull(channelMapping, "channelMapping must not be null"); + this.channelMapping = channelMapping; } private void createAdvisor() { - if (this.channelResolver == null) { - throw new IllegalStateException("channelResolver is required"); + if (this.channelMapping == null) { + throw new IllegalStateException("channelMapping is required"); } this.advisor = new PublisherAnnotationAdvisor(this.publisherAnnotationType, this.channelNameAttribute, - this.channelResolver); + this.channelMapping); } public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { diff --git a/spring-eai-core/src/main/java/org/springframework/integration/bus/MessageBus.java b/spring-eai-core/src/main/java/org/springframework/integration/bus/MessageBus.java index b40c2b48de..fac972cd5c 100644 --- a/spring-eai-core/src/main/java/org/springframework/integration/bus/MessageBus.java +++ b/spring-eai-core/src/main/java/org/springframework/integration/bus/MessageBus.java @@ -31,7 +31,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.Lifecycle; import org.springframework.integration.MessagingException; -import org.springframework.integration.channel.ChannelResolver; +import org.springframework.integration.channel.ChannelMapping; import org.springframework.integration.channel.MessageChannel; import org.springframework.integration.channel.PointToPointChannel; import org.springframework.integration.endpoint.MessageEndpoint; @@ -44,7 +44,7 @@ import org.springframework.util.Assert; * * @author Mark Fisher */ -public class MessageBus implements ChannelResolver, ApplicationContextAware, Lifecycle { +public class MessageBus implements ChannelMapping, ApplicationContextAware, Lifecycle { private Log logger = LogFactory.getLog(this.getClass()); @@ -113,7 +113,7 @@ public class MessageBus implements ChannelResolver, ApplicationContextAware, Lif this.dispatcherExecutor = new ScheduledThreadPoolExecutor(this.dispatcherTasks.size() > 0 ? this.dispatcherTasks.size() : 1); } - public MessageChannel resolve(String channelName) { + public MessageChannel getChannel(String channelName) { return this.channels.get(channelName); } @@ -123,7 +123,7 @@ public class MessageBus implements ChannelResolver, ApplicationContextAware, Lif public void registerEndpoint(String name, MessageEndpoint endpoint) { this.endpoints.put(name, endpoint); - endpoint.setChannelResolver(this); + endpoint.setChannelMapping(this); } public void activateSubscription(Subscription subscription) { diff --git a/spring-eai-core/src/main/java/org/springframework/integration/channel/ChannelResolver.java b/spring-eai-core/src/main/java/org/springframework/integration/channel/ChannelMapping.java similarity index 90% rename from spring-eai-core/src/main/java/org/springframework/integration/channel/ChannelResolver.java rename to spring-eai-core/src/main/java/org/springframework/integration/channel/ChannelMapping.java index 9d277eb591..eeede640ce 100644 --- a/spring-eai-core/src/main/java/org/springframework/integration/channel/ChannelResolver.java +++ b/spring-eai-core/src/main/java/org/springframework/integration/channel/ChannelMapping.java @@ -21,8 +21,8 @@ package org.springframework.integration.channel; * * @author Mark Fisher */ -public interface ChannelResolver { +public interface ChannelMapping { - MessageChannel resolve(String channelName); + MessageChannel getChannel(String channelName); } diff --git a/spring-eai-core/src/main/java/org/springframework/integration/endpoint/GenericMessageEndpoint.java b/spring-eai-core/src/main/java/org/springframework/integration/endpoint/GenericMessageEndpoint.java index 0de86946ac..d7bca04620 100644 --- a/spring-eai-core/src/main/java/org/springframework/integration/endpoint/GenericMessageEndpoint.java +++ b/spring-eai-core/src/main/java/org/springframework/integration/endpoint/GenericMessageEndpoint.java @@ -19,7 +19,7 @@ package org.springframework.integration.endpoint; import org.springframework.integration.MessageHandlingException; import org.springframework.integration.MessagingConfigurationException; import org.springframework.integration.bus.ConsumerPolicy; -import org.springframework.integration.channel.ChannelResolver; +import org.springframework.integration.channel.ChannelMapping; import org.springframework.integration.channel.MessageChannel; import org.springframework.integration.handler.MessageHandler; import org.springframework.integration.message.Message; @@ -45,7 +45,7 @@ public class GenericMessageEndpoint implements MessageEndpoint { private MessageHandler handler; - private ChannelResolver channelResolver; + private ChannelMapping channelMapping; private ConsumerPolicy consumerPolicy; @@ -87,10 +87,10 @@ public class GenericMessageEndpoint implements MessageEndpoint { } /** - * Set the channel resolver to use for resolving channels by name. + * Set the channel mapping to use for looking up channels by name. */ - public void setChannelResolver(ChannelResolver channelResolver) { - this.channelResolver = channelResolver; + public void setChannelMapping(ChannelMapping channelMapping) { + this.channelMapping = channelMapping; } @@ -100,7 +100,7 @@ public class GenericMessageEndpoint implements MessageEndpoint { throw new MessagingConfigurationException( "endpoint must have either a 'handler' or 'defaultOutputChannelName'"); } - MessageChannel replyChannel = this.channelResolver.resolve(this.defaultOutputChannelName); + MessageChannel replyChannel = this.channelMapping.getChannel(this.defaultOutputChannelName); replyChannel.send(message); return; } @@ -117,14 +117,14 @@ public class GenericMessageEndpoint implements MessageEndpoint { } private MessageChannel resolveReplyChannel(Message message) { - if (this.channelResolver == null) { + if (this.channelMapping == null) { return null; } String replyChannelName = message.getHeader().getReplyChannelName(); if (replyChannelName != null && replyChannelName.trim().length() > 0) { - return this.channelResolver.resolve(replyChannelName); + return this.channelMapping.getChannel(replyChannelName); } - return this.channelResolver.resolve(this.defaultOutputChannelName); + return this.channelMapping.getChannel(this.defaultOutputChannelName); } } diff --git a/spring-eai-core/src/main/java/org/springframework/integration/endpoint/MessageEndpoint.java b/spring-eai-core/src/main/java/org/springframework/integration/endpoint/MessageEndpoint.java index 66e6dff963..7483fe2418 100644 --- a/spring-eai-core/src/main/java/org/springframework/integration/endpoint/MessageEndpoint.java +++ b/spring-eai-core/src/main/java/org/springframework/integration/endpoint/MessageEndpoint.java @@ -16,7 +16,7 @@ package org.springframework.integration.endpoint; -import org.springframework.integration.channel.ChannelResolver; +import org.springframework.integration.channel.ChannelMapping; import org.springframework.integration.message.Message; /** @@ -30,7 +30,7 @@ public interface MessageEndpoint { void setDefaultOutputChannelName(String defaultOutputChannelName); - void setChannelResolver(ChannelResolver channelResolver); + void setChannelMapping(ChannelMapping channelMapping); void messageReceived(Message message); diff --git a/spring-eai-core/src/test/java/org/springframework/integration/aop/PublisherAnnotationAdvisorTests.java b/spring-eai-core/src/test/java/org/springframework/integration/aop/PublisherAnnotationAdvisorTests.java index 4e98c87c70..7739e4ee7b 100644 --- a/spring-eai-core/src/test/java/org/springframework/integration/aop/PublisherAnnotationAdvisorTests.java +++ b/spring-eai-core/src/test/java/org/springframework/integration/aop/PublisherAnnotationAdvisorTests.java @@ -24,7 +24,7 @@ import org.junit.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.integration.annotation.Publisher; -import org.springframework.integration.channel.ChannelResolver; +import org.springframework.integration.channel.ChannelMapping; import org.springframework.integration.channel.MessageChannel; import org.springframework.integration.channel.PointToPointChannel; import org.springframework.integration.message.Message; @@ -37,15 +37,15 @@ public class PublisherAnnotationAdvisorTests { @Test public void testPublisherAnnotation() { final MessageChannel channel = new PointToPointChannel(); - ChannelResolver channelResolver = new ChannelResolver() { - public MessageChannel resolve(String channelName) { + ChannelMapping channelMapping = new ChannelMapping() { + public MessageChannel getChannel(String channelName) { if (channelName.equals("testChannel")) { return channel; } return null; } }; - PublisherAnnotationAdvisor advisor = new PublisherAnnotationAdvisor(channelResolver); + PublisherAnnotationAdvisor advisor = new PublisherAnnotationAdvisor(channelMapping); TestService proxy = (TestService) this.createProxy(new TestServiceImpl("hello world"), advisor); proxy.publisherTest(); Message message = channel.receive(0); @@ -56,15 +56,15 @@ public class PublisherAnnotationAdvisorTests { @Test public void testNoPublisherAnnotation() { final MessageChannel channel = new PointToPointChannel(); - ChannelResolver channelResolver = new ChannelResolver() { - public MessageChannel resolve(String channelName) { + ChannelMapping channelMapping = new ChannelMapping() { + public MessageChannel getChannel(String channelName) { if (channelName.equals("testChannel")) { return channel; } return null; } }; - PublisherAnnotationAdvisor advisor = new PublisherAnnotationAdvisor(channelResolver); + PublisherAnnotationAdvisor advisor = new PublisherAnnotationAdvisor(channelMapping); TestService proxy = (TestService) this.createProxy(new TestServiceImpl("hello world"), advisor); proxy.noPublisherTest(); Message message = channel.receive(0); diff --git a/spring-eai-core/src/test/java/org/springframework/integration/aop/publisherAnnotationPostProcessorTests.xml b/spring-eai-core/src/test/java/org/springframework/integration/aop/publisherAnnotationPostProcessorTests.xml index fafcb9c56b..5d508928bd 100644 --- a/spring-eai-core/src/test/java/org/springframework/integration/aop/publisherAnnotationPostProcessorTests.xml +++ b/spring-eai-core/src/test/java/org/springframework/integration/aop/publisherAnnotationPostProcessorTests.xml @@ -11,7 +11,7 @@ - + diff --git a/spring-eai-core/src/test/java/org/springframework/integration/endpoint/GenericMessageEndpointTests.java b/spring-eai-core/src/test/java/org/springframework/integration/endpoint/GenericMessageEndpointTests.java index 35f30c2398..78bc05c5cd 100644 --- a/spring-eai-core/src/test/java/org/springframework/integration/endpoint/GenericMessageEndpointTests.java +++ b/spring-eai-core/src/test/java/org/springframework/integration/endpoint/GenericMessageEndpointTests.java @@ -24,7 +24,6 @@ import org.junit.Test; import org.springframework.integration.bus.ConsumerPolicy; import org.springframework.integration.bus.MessageBus; import org.springframework.integration.bus.Subscription; -import org.springframework.integration.channel.ChannelResolver; import org.springframework.integration.channel.MessageChannel; import org.springframework.integration.channel.PointToPointChannel; import org.springframework.integration.handler.MessageHandler; @@ -77,18 +76,9 @@ public class GenericMessageEndpointTests { return new DocumentMessage("123", "hello " + message.getPayload()); } }; - ChannelResolver channelResolver = new ChannelResolver() { - public MessageChannel resolve(String channelName) { - if (channelName.equals("replyChannel")) { - return replyChannel; - } - return null; - } - }; GenericMessageEndpoint endpoint = new GenericMessageEndpoint(); endpoint.setInputChannelName("testChannel"); endpoint.setHandler(handler); - endpoint.setChannelResolver(channelResolver); MessageBus bus = new MessageBus(); bus.registerChannel("testChannel", channel); bus.registerEndpoint("testEndpoint", endpoint);