INT-1614 refactored inbound parsers to inherit from common class, adding the actual base class

This commit is contained in:
Oleg Zhurakousky
2010-11-15 14:34:23 -05:00
parent 7ac7b51fc9
commit 0b6011bf5f

View File

@@ -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<String> receiveAttrs = new HashSet<String>(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();
}