diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/factory/AbstractChannelFactory.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/factory/AbstractChannelFactory.java index ea5b6928a2..befd28625b 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/factory/AbstractChannelFactory.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/factory/AbstractChannelFactory.java @@ -42,11 +42,11 @@ public abstract class AbstractChannelFactory implements ChannelFactory { } return channel; } - + /** * Factory method to be overridden by subclasses. It assumes that subclasses will return * subclasses of AbstractMessageChannel. */ protected abstract AbstractMessageChannel createChannelInternal(DispatcherPolicy dispatcherPolicy); -} \ No newline at end of file +} diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/factory/DefaultChannelFactoryBean.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/factory/DefaultChannelFactoryBean.java index 4b71d2d935..b04baafd53 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/factory/DefaultChannelFactoryBean.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/factory/DefaultChannelFactoryBean.java @@ -29,11 +29,12 @@ import org.springframework.integration.channel.MessageChannel; import org.springframework.util.Assert; /** - * Creates a channel by delegating to the current message bus-configured + * Creates a channel by delegating to the current message bus' configured * ChannelFactory. Tries to retrieve the {@link ChannelFactory} from the * single {@link MessageBus} defined in the {@link ApplicationContext}. * As a {@link FactoryBean}, this class is solely intended to be used within * an ApplicationContext. + * * @author Marius Bogoevici */ public class DefaultChannelFactoryBean implements ApplicationContextAware, FactoryBean{ @@ -43,15 +44,14 @@ public class DefaultChannelFactoryBean implements ApplicationContextAware, Facto private volatile List interceptors; private volatile DispatcherPolicy dispatcherPolicy; - - private volatile boolean publisherSubscriber; - + public DefaultChannelFactoryBean(DispatcherPolicy dispatcherPolicy) { this.dispatcherPolicy = dispatcherPolicy; } - + + @SuppressWarnings("unchecked") public void setApplicationContext(ApplicationContext applicationContext){ Map map = applicationContext.getBeansOfType(MessageBus.class); Assert.state(map.size() <= 1, "There is more than one MessageBus in the ApplicationContext"); @@ -59,7 +59,7 @@ public class DefaultChannelFactoryBean implements ApplicationContextAware, Facto this.channelFactory = new QueueChannelFactory(); } else { - this.channelFactory = ((MessageBus)map.values().iterator().next()).getChannelFactory(); + this.channelFactory = ((MessageBus) map.values().iterator().next()).getChannelFactory(); } } @@ -72,7 +72,7 @@ public class DefaultChannelFactoryBean implements ApplicationContextAware, Facto return channelFactory.getChannel(dispatcherPolicy, interceptors); } - public Class getObjectType() { + public Class getObjectType() { return MessageChannel.class; } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/factory/RendezvousChannelFactory.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/factory/RendezvousChannelFactory.java index 5432b2bd7f..704656effa 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/factory/RendezvousChannelFactory.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/factory/RendezvousChannelFactory.java @@ -22,8 +22,8 @@ import org.springframework.integration.channel.RendezvousChannel; /** * A {@link ChannelFactory} for creating {@link RendezvousChannel} instances. + * * @author Marius Bogoevici - * */ public class RendezvousChannelFactory extends AbstractChannelFactory { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/MessageBusParser.java b/spring-integration-core/src/main/java/org/springframework/integration/config/MessageBusParser.java index ee5edc88a1..c696957320 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/MessageBusParser.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/MessageBusParser.java @@ -16,6 +16,10 @@ package org.springframework.integration.config; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.RuntimeBeanReference; @@ -28,11 +32,7 @@ import org.springframework.core.Conventions; import org.springframework.integration.ConfigurationException; import org.springframework.integration.bus.MessageBus; import org.springframework.integration.bus.MessageBusAwareBeanPostProcessor; -import org.springframework.integration.endpoint.ConcurrencyPolicy; import org.springframework.util.StringUtils; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; /** * Parser for the message-bus element of the integration namespace. @@ -95,30 +95,19 @@ public class MessageBusParser extends AbstractSimpleBeanDefinitionParser { for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { - processIfConcurrencyElement(beanDefinition, child); - processIfChannelFactoryElement(beanDefinition, child); + String localName = child.getLocalName(); + if (DEFAULT_CONCURRENCY_ELEMENT.equals(localName)) { + beanDefinition.addPropertyValue(DEFAULT_CONCURRENCY_PROPERTY, + IntegrationNamespaceUtils.parseConcurrencyPolicy((Element) child)); + } + else if (CHANNEL_FACTORY_ELEMENT.equals(localName)) { + beanDefinition.addPropertyReference(CHANNEL_FACTORY_PROPERTY, + ((Element) child).getAttribute(REFERENCE_ATTRIBUTE)); + } } } } - - private void processIfConcurrencyElement(BeanDefinitionBuilder beanDefinition, Node node) { - String localName = node.getLocalName(); - if (DEFAULT_CONCURRENCY_ELEMENT.equals(localName)) { - ConcurrencyPolicy policy = IntegrationNamespaceUtils.parseConcurrencyPolicy((Element) node); - beanDefinition.addPropertyValue(DEFAULT_CONCURRENCY_PROPERTY, policy); - } - - } - - private void processIfChannelFactoryElement(BeanDefinitionBuilder beanDefinition, Node node) { - String localName = node.getLocalName(); - if (CHANNEL_FACTORY_ELEMENT.equals(localName)) { - beanDefinition.addPropertyReference(CHANNEL_FACTORY_PROPERTY, ((Element) node) - .getAttribute(REFERENCE_ATTRIBUTE)); - } - } - @Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { super.doParse(element, parserContext, builder);