diff --git a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/AbstractFtpOutboundChannelAdapterParser.java b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/AbstractFtpOutboundChannelAdapterParser.java index 7781e5af24..76b6bf261b 100644 --- a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/AbstractFtpOutboundChannelAdapterParser.java +++ b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/AbstractFtpOutboundChannelAdapterParser.java @@ -31,11 +31,17 @@ public abstract class AbstractFtpOutboundChannelAdapterParser extends AbstractOu @Override protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) { - BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(this.getClassName()); - IntegrationNamespaceUtils.setValueIfAttributeDefined(builder,element,"charset"); - IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder,element,"filename-generator", "fileNameGenerator"); - IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder,element,"client-factory"); - return builder.getBeanDefinition(); + BeanDefinitionBuilder handlerBuilder = BeanDefinitionBuilder.genericBeanDefinition(this.getClassName()); + + BeanDefinitionBuilder poolBuilder = + BeanDefinitionBuilder.genericBeanDefinition("org.springframework.integration.ftp.session.QueuedFtpClientPool"); + poolBuilder.addConstructorArgReference(element.getAttribute("client-factory")); + + handlerBuilder.addConstructorArgValue(poolBuilder.getBeanDefinition()); + + IntegrationNamespaceUtils.setValueIfAttributeDefined(handlerBuilder, element, "charset"); + IntegrationNamespaceUtils.setReferenceIfAttributeDefined(handlerBuilder, element,"filename-generator", "fileNameGenerator"); + return handlerBuilder.getBeanDefinition(); } protected abstract String getClassName(); diff --git a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParser.java b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParser.java index 4f510df06d..ca954a83cb 100644 --- a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParser.java +++ b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParser.java @@ -28,7 +28,7 @@ public class FtpOutboundChannelAdapterParser extends AbstractFtpOutboundChannelA @Override protected String getClassName() { - return "org.springframework.integration.ftp.config.FtpSendingMessageHandlerFactoryBean"; + return "org.springframework.integration.ftp.outbound.FtpSendingMessageHandler"; } } diff --git a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpSendingMessageHandlerFactoryBean.java b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpSendingMessageHandlerFactoryBean.java deleted file mode 100644 index 166a57ffc3..0000000000 --- a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpSendingMessageHandlerFactoryBean.java +++ /dev/null @@ -1,80 +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.ftp.config; - -import org.springframework.beans.factory.config.AbstractFactoryBean; -import org.springframework.integration.file.FileNameGenerator; -import org.springframework.integration.ftp.outbound.FtpSendingMessageHandler; -import org.springframework.integration.ftp.session.AbstractFtpClientFactory; -import org.springframework.integration.ftp.session.DefaultFtpClientFactory; -import org.springframework.integration.ftp.session.QueuedFtpClientPool; - -/** - * A factory bean implementation that handles constructing an outbound FTP - * adapter. - * - * @author Iwein Fuld - * @author Josh Long - * @author Oleg Zhurakousky - * @since 2.0 - */ -class FtpSendingMessageHandlerFactoryBean extends AbstractFactoryBean { - - private volatile String charset; - - private volatile FileNameGenerator fileNameGenerator; - - private volatile AbstractFtpClientFactory clientFactory; - - public void setClientFactory(AbstractFtpClientFactory clientFactory) { - this.clientFactory = clientFactory; - } - - public void setCharset(String charset) { - this.charset = charset; - } - - public void setFileNameGenerator(FileNameGenerator fileNameGenerator) { - this.fileNameGenerator = fileNameGenerator; - } - - @Override - public Class getObjectType() { - return FtpSendingMessageHandler.class; - } - - protected AbstractFtpClientFactory createClientFactory(){ - return new DefaultFtpClientFactory(); - } - - @Override - protected FtpSendingMessageHandler createInstance() throws Exception { - QueuedFtpClientPool queuedFtpClientPool = new QueuedFtpClientPool(15, this.clientFactory); - FtpSendingMessageHandler ftpSendingMessageHandler = new FtpSendingMessageHandler( - queuedFtpClientPool); - if (this.fileNameGenerator != null){ - ftpSendingMessageHandler.setFileNameGenerator(this.fileNameGenerator); - } - - if (this.charset != null) { - ftpSendingMessageHandler.setCharset(this.charset); - } - ftpSendingMessageHandler.afterPropertiesSet(); - return ftpSendingMessageHandler; - } - -}