From 0b6011bf5fd593747ded3de94e9a60cfea23371c Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Mon, 15 Nov 2010 14:34:23 -0500 Subject: [PATCH] INT-1614 refactored inbound parsers to inherit from common class, adding the actual base class --- ...bstractFtpInboundChannelAdapterParser.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/AbstractFtpInboundChannelAdapterParser.java diff --git a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/AbstractFtpInboundChannelAdapterParser.java b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/AbstractFtpInboundChannelAdapterParser.java new file mode 100644 index 0000000000..086ee9cc85 --- /dev/null +++ b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/AbstractFtpInboundChannelAdapterParser.java @@ -0,0 +1,43 @@ +/** + * + */ +package org.springframework.integration.ftp.config; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import org.w3c.dom.Element; + +import org.springframework.beans.BeanMetadataElement; +import org.springframework.beans.factory.config.RuntimeBeanReference; +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.beans.factory.support.BeanDefinitionReaderUtils; +import org.springframework.beans.factory.xml.ParserContext; +import org.springframework.integration.config.xml.AbstractPollingInboundChannelAdapterParser; +import org.springframework.integration.config.xml.IntegrationNamespaceUtils; + +/** + * @author ozhurakousky + * + */ +public abstract class AbstractFtpInboundChannelAdapterParser extends AbstractPollingInboundChannelAdapterParser { + + private Set receiveAttrs = new HashSet(Arrays.asList( + "auto-delete-remote-files-on-sync,filename-pattern,local-working-directory".split(","))); + + @Override + protected BeanMetadataElement parseSource(Element element, ParserContext parserContext) { + BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(this.getClassName()); + IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "filter"); + for (String a : receiveAttrs) { + IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, a); + } + FtpNamespaceParserSupport.configureCoreFtpClient(builder, element, parserContext); + String beanName = BeanDefinitionReaderUtils.registerWithGeneratedName( + builder.getBeanDefinition(), parserContext.getRegistry()); + return new RuntimeBeanReference(beanName); + } + + protected abstract String getClassName(); +}