cleaning up SFTP + FTP code
This commit is contained in:
@@ -14,6 +14,7 @@ import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.integration.file.FileReadingMessageSource;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
|
||||
import java.io.File;
|
||||
@@ -94,7 +95,7 @@ public class FTPMessageSourceFactoryBean extends AbstractFactoryBean<FTPFileSour
|
||||
File ftpTmp = new File(tmp, "ftpInbound");
|
||||
this.localWorkingDirectory = "file://" + ftpTmp.getAbsolutePath();
|
||||
}
|
||||
assert !StringUtils.isEmpty(this.localWorkingDirectory) : "the local working directory can't be null!";
|
||||
Assert.hasText( this.localWorkingDirectory , "the local working directory can't be null!" );
|
||||
|
||||
ResourceEditor resourceEditor = new ResourceEditor(this.resourceLoader);
|
||||
resourceEditor.setAsText(this.localWorkingDirectory);
|
||||
@@ -130,7 +131,6 @@ public class FTPMessageSourceFactoryBean extends AbstractFactoryBean<FTPFileSour
|
||||
defaultFTPClientFactory.setPort(this.port);
|
||||
defaultFTPClientFactory.setRemoteWorkingDirectory(this.remoteDirectory);
|
||||
defaultFTPClientFactory.setUsername(this.username);
|
||||
|
||||
defaultFTPClientFactory.setClientMode(this.clientMode);
|
||||
|
||||
QueuedFTPClientPool queuedFTPClientPool = new QueuedFTPClientPool(15, defaultFTPClientFactory);
|
||||
|
||||
@@ -54,13 +54,11 @@ public class FTPSendingMessageHandlerFactoryBean extends AbstractFactoryBean<FTP
|
||||
defaultFTPClientFactory.setPort(this.port);
|
||||
defaultFTPClientFactory.setRemoteWorkingDirectory(this.remoteDirectory);
|
||||
defaultFTPClientFactory.setUsername(this.username);
|
||||
|
||||
defaultFTPClientFactory.setClientMode(this.clientMode);
|
||||
|
||||
QueuedFTPClientPool queuedFTPClientPool = new QueuedFTPClientPool(15, defaultFTPClientFactory);
|
||||
|
||||
FTPSendingMessageHandler ftpSendingMessageHandler = new FTPSendingMessageHandler(queuedFTPClientPool);
|
||||
|
||||
ftpSendingMessageHandler.afterPropertiesSet();
|
||||
|
||||
return ftpSendingMessageHandler;
|
||||
|
||||
@@ -20,11 +20,9 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
|
||||
import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser;
|
||||
import org.springframework.integration.config.xml.AbstractPollingInboundChannelAdapterParser;
|
||||
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -83,7 +81,8 @@ public class FTPNamespaceHandler extends NamespaceHandlerSupport {
|
||||
protected String parseSource(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(PACKAGE_NAME + ".FTPMessageSourceFactoryBean");
|
||||
|
||||
for (String p : ("auto-create-directories,username,password,host,port," + "remote-directory,local-working-directory").split(",")) { //auto-delete-remote-files-on-sync
|
||||
for (String p : ("auto-create-directories,username,password,host,port," + "remote-directory,local-working-directory").split(",")) {
|
||||
//auto-delete-remote-files-on-sync
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, p);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user