INT-1471, more polishing, consolidated Outbound adapter parsers

This commit is contained in:
Oleg Zhurakousky
2010-10-28 09:00:38 -04:00
committed by Chris Beams
parent 20dd46ea4a
commit d2dc2f5bd4
4 changed files with 18 additions and 54 deletions

View File

@@ -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();
}
}

View File

@@ -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();
}

View File

@@ -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) {

View File

@@ -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());
}
}