diff --git a/spring-integration-twitter/src/main/java/org/springframework/integration/twitter/config/OutboundTimelineUpdateMessageHandlerParser.java b/spring-integration-twitter/src/main/java/org/springframework/integration/twitter/config/OutboundTimelineUpdateMessageHandlerParser.java deleted file mode 100644 index d70e476ecc..0000000000 --- a/spring-integration-twitter/src/main/java/org/springframework/integration/twitter/config/OutboundTimelineUpdateMessageHandlerParser.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2002-2010 the original author or authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.integration.twitter.config; - -import org.springframework.beans.factory.support.AbstractBeanDefinition; -import org.springframework.beans.factory.support.BeanDefinitionBuilder; -import org.springframework.beans.factory.xml.ParserContext; -import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser; -import org.springframework.integration.config.xml.IntegrationNamespaceUtils; -import org.w3c.dom.Element; - -import static org.springframework.integration.twitter.config.TwitterNamespaceHandler.BASE_PACKAGE; - -/** - * Parser for the 'outbound-update-channel-adapter' element. - * - * @author Josh Long - * @since 2.0 - */ -public class OutboundTimelineUpdateMessageHandlerParser extends AbstractOutboundChannelAdapterParser { - - @Override - protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) { - BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition( - BASE_PACKAGE + ".outbound.OutboundTimelineUpdateMessageHandler"); - IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "twitter-connection", "configuration"); - return builder.getBeanDefinition(); - } - -} diff --git a/spring-integration-twitter/src/main/java/org/springframework/integration/twitter/config/OutboundDirectMessageMessageHandlerParser.java b/spring-integration-twitter/src/main/java/org/springframework/integration/twitter/config/TwitterMessageHandlerParser.java similarity index 71% rename from spring-integration-twitter/src/main/java/org/springframework/integration/twitter/config/OutboundDirectMessageMessageHandlerParser.java rename to spring-integration-twitter/src/main/java/org/springframework/integration/twitter/config/TwitterMessageHandlerParser.java index c98c1ea00f..ebe26ec40f 100644 --- a/spring-integration-twitter/src/main/java/org/springframework/integration/twitter/config/OutboundDirectMessageMessageHandlerParser.java +++ b/spring-integration-twitter/src/main/java/org/springframework/integration/twitter/config/TwitterMessageHandlerParser.java @@ -27,17 +27,25 @@ import org.springframework.integration.config.xml.AbstractOutboundChannelAdapter import org.springframework.integration.config.xml.IntegrationNamespaceUtils; /** - * Parser for 'outbound-dm-channel-adapter' element + * Parser for all outbound Twitter adapters * * @author Josh Long + * @author Oleg Zhurakousky * @since 2.0 */ -public class OutboundDirectMessageMessageHandlerParser extends AbstractOutboundChannelAdapterParser { +public class TwitterMessageHandlerParser extends AbstractOutboundChannelAdapterParser { @Override protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) { - BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition( - BASE_PACKAGE + ".outbound.OutboundDirectMessageMessageHandler"); + String elementName = element.getLocalName().trim(); + String className = null; + if ("outbound-update-channel-adapter".equals(elementName)) { + className = BASE_PACKAGE + ".outbound.OutboundTimelineUpdateMessageHandler"; + } + else if ("outbound-dm-channel-adapter".equals(elementName)) { + className = BASE_PACKAGE + ".outbound.OutboundDirectMessageMessageHandler"; + } + BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(className); IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "twitter-connection", "configuration"); return builder.getBeanDefinition(); } diff --git a/spring-integration-twitter/src/main/java/org/springframework/integration/twitter/config/InboundMessageSourceParser.java b/spring-integration-twitter/src/main/java/org/springframework/integration/twitter/config/TwitterMessageSourceParser.java similarity index 97% rename from spring-integration-twitter/src/main/java/org/springframework/integration/twitter/config/InboundMessageSourceParser.java rename to spring-integration-twitter/src/main/java/org/springframework/integration/twitter/config/TwitterMessageSourceParser.java index b99e11fd61..d17e549ff6 100644 --- a/spring-integration-twitter/src/main/java/org/springframework/integration/twitter/config/InboundMessageSourceParser.java +++ b/spring-integration-twitter/src/main/java/org/springframework/integration/twitter/config/TwitterMessageSourceParser.java @@ -34,7 +34,7 @@ import org.springframework.integration.config.xml.IntegrationNamespaceUtils; * @author Oleg Zhurakousky * @since 2.0 */ -public class InboundMessageSourceParser extends AbstractPollingInboundChannelAdapterParser { +public class TwitterMessageSourceParser extends AbstractPollingInboundChannelAdapterParser { @Override protected BeanMetadataElement parseSource(Element element, ParserContext parserContext) { diff --git a/spring-integration-twitter/src/main/java/org/springframework/integration/twitter/config/TwitterNamespaceHandler.java b/spring-integration-twitter/src/main/java/org/springframework/integration/twitter/config/TwitterNamespaceHandler.java index 1f86086895..ac87d5da85 100644 --- a/spring-integration-twitter/src/main/java/org/springframework/integration/twitter/config/TwitterNamespaceHandler.java +++ b/spring-integration-twitter/src/main/java/org/springframework/integration/twitter/config/TwitterNamespaceHandler.java @@ -35,13 +35,13 @@ public class TwitterNamespaceHandler extends AbstractIntegrationNamespaceHandler registerBeanDefinitionParser("twitter-connection", new ConnectionParser()); // inbound - registerBeanDefinitionParser("inbound-update-channel-adapter", new InboundMessageSourceParser()); - registerBeanDefinitionParser("inbound-dm-channel-adapter", new InboundMessageSourceParser()); - registerBeanDefinitionParser("inbound-mention-channel-adapter", new InboundMessageSourceParser()); + registerBeanDefinitionParser("inbound-update-channel-adapter", new TwitterMessageSourceParser()); + registerBeanDefinitionParser("inbound-dm-channel-adapter", new TwitterMessageSourceParser()); + registerBeanDefinitionParser("inbound-mention-channel-adapter", new TwitterMessageSourceParser()); // outbound - registerBeanDefinitionParser("outbound-update-channel-adapter", new OutboundTimelineUpdateMessageHandlerParser()); - registerBeanDefinitionParser("outbound-dm-channel-adapter", new OutboundDirectMessageMessageHandlerParser()); + registerBeanDefinitionParser("outbound-update-channel-adapter", new TwitterMessageHandlerParser()); + registerBeanDefinitionParser("outbound-dm-channel-adapter", new TwitterMessageHandlerParser()); } }