INT-1562 created 'client' package
This commit is contained in:
@@ -1,98 +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;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.net.ssl.KeyManager;
|
||||
import javax.net.ssl.TrustManager;
|
||||
|
||||
/**
|
||||
* Factors out the client factory creation.
|
||||
*
|
||||
* @author Josh Long
|
||||
*/
|
||||
public class ClientFactorySupport {
|
||||
|
||||
public static DefaultFtpsClientFactory ftpsClientFactory(String host, int port, String remoteWorkingDirectory, String user, String password, int fileType,
|
||||
int clientMode, String prot, String protocol, String authValue,
|
||||
Boolean implicit, TrustManager trustManager, KeyManager keyManager,
|
||||
Boolean sessionCreation, Boolean useClientMode,
|
||||
Boolean wantsClientAuth, Boolean needClientAuth, String[] cipherSuites) {
|
||||
DefaultFtpsClientFactory defaultFtpClientFactory = new DefaultFtpsClientFactory();
|
||||
defaultFtpClientFactory.setHost(host);
|
||||
defaultFtpClientFactory.setPassword(password);
|
||||
defaultFtpClientFactory.setPort(port);
|
||||
defaultFtpClientFactory.setRemoteWorkingDirectory(remoteWorkingDirectory);
|
||||
defaultFtpClientFactory.setUsername(user);
|
||||
defaultFtpClientFactory.setFileType(fileType);
|
||||
defaultFtpClientFactory.setClientMode(clientMode);
|
||||
if (cipherSuites != null) {
|
||||
defaultFtpClientFactory.setCipherSuites(cipherSuites);
|
||||
}
|
||||
if (StringUtils.hasText(prot)) {
|
||||
defaultFtpClientFactory.setProt(prot);
|
||||
}
|
||||
if (StringUtils.hasText(protocol)) {
|
||||
defaultFtpClientFactory.setProtocol(protocol);
|
||||
}
|
||||
if (StringUtils.hasText(authValue)) {
|
||||
defaultFtpClientFactory.setAuthValue(authValue);
|
||||
}
|
||||
if (null != implicit) {
|
||||
defaultFtpClientFactory.setImplicit(implicit);
|
||||
}
|
||||
if (trustManager != null) {
|
||||
defaultFtpClientFactory.setTrustManager(trustManager);
|
||||
}
|
||||
if (keyManager != null) {
|
||||
defaultFtpClientFactory.setKeyManager(keyManager);
|
||||
}
|
||||
if (needClientAuth != null) {
|
||||
defaultFtpClientFactory.setNeedClientAuth(needClientAuth);
|
||||
}
|
||||
if (wantsClientAuth != null) {
|
||||
defaultFtpClientFactory.setWantsClientAuth(wantsClientAuth);
|
||||
}
|
||||
if (sessionCreation != null) {
|
||||
defaultFtpClientFactory.setSessionCreation(sessionCreation);
|
||||
}
|
||||
if (useClientMode != null) {
|
||||
defaultFtpClientFactory.setUseClientMode(useClientMode);
|
||||
}
|
||||
return defaultFtpClientFactory;
|
||||
}
|
||||
|
||||
public static DefaultFtpClientFactory ftpClientFactory(String host,
|
||||
int port,
|
||||
String remoteWorkingDirectory,
|
||||
String user,
|
||||
String password,
|
||||
int clientMode,
|
||||
int fileType) {
|
||||
DefaultFtpClientFactory defaultFtpClientFactory = new DefaultFtpClientFactory();
|
||||
defaultFtpClientFactory.setHost(host);
|
||||
defaultFtpClientFactory.setPassword(password);
|
||||
defaultFtpClientFactory.setPort(port);
|
||||
defaultFtpClientFactory.setRemoteWorkingDirectory(remoteWorkingDirectory);
|
||||
defaultFtpClientFactory.setUsername(user);
|
||||
defaultFtpClientFactory.setClientMode(clientMode);
|
||||
defaultFtpClientFactory.setFileType(fileType);
|
||||
return defaultFtpClientFactory;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.ftp;
|
||||
package org.springframework.integration.ftp.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.SocketException;
|
||||
@@ -31,7 +31,7 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* base class for the other {@link org.springframework.integration.ftp.FtpClientFactory} implementations.
|
||||
* base class for the other {@link org.springframework.integration.ftp.client.FtpClientFactory} implementations.
|
||||
* Most of this came out of the {@link DefaultFtpClientFactory} and was refactored into a base class
|
||||
*
|
||||
* @author Iwein Fuld
|
||||
@@ -14,10 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.ftp;
|
||||
package org.springframework.integration.ftp.client;
|
||||
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
|
||||
|
||||
/**
|
||||
* Default implementation of FtpClientFactory.
|
||||
*
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.ftp;
|
||||
package org.springframework.integration.ftp.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.SocketException;
|
||||
@@ -28,7 +28,7 @@ import org.apache.commons.net.ftp.FTPSClient;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* provides a working FTPS implementation. Based heavily on {@link org.springframework.integration.ftp.DefaultFtpClientFactory}
|
||||
* provides a working FTPS implementation. Based heavily on {@link org.springframework.integration.ftp.client.DefaultFtpClientFactory}
|
||||
*
|
||||
* @author Josh Long
|
||||
* @author Iwein Fuld
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.ftp;
|
||||
package org.springframework.integration.ftp.client;
|
||||
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
|
||||
@@ -14,10 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.ftp;
|
||||
package org.springframework.integration.ftp.client;
|
||||
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
|
||||
|
||||
/**
|
||||
* A pool of {@link FTPClient} instances. The pool can be used to control the
|
||||
* number of open FTP connections and reuse these connections efficiently.
|
||||
@@ -14,11 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.ftp;
|
||||
package org.springframework.integration.ftp.client;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -21,7 +21,8 @@ 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.springframework.integration.ftp.FtpSendingMessageHandlerFactoryBean;
|
||||
import org.springframework.integration.ftp.outbound.FtpSendingMessageHandlerFactoryBean;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,7 @@ 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;
|
||||
import org.springframework.integration.ftp.FtpRemoteFileSystemSynchronizingMessageSourceFactoryBean;
|
||||
import org.springframework.integration.ftp.inbound.FtpRemoteFileSystemSynchronizingMessageSourceFactoryBean;
|
||||
|
||||
/**
|
||||
* Parser for the FTP inbound-channel-adapter.
|
||||
|
||||
@@ -23,7 +23,7 @@ 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.springframework.integration.ftp.FtpsSendingMessageHandlerFactoryBean;
|
||||
import org.springframework.integration.ftp.outbound.FtpsSendingMessageHandlerFactoryBean;
|
||||
|
||||
/**
|
||||
* Parser for the FTPS outbound-channel-adapter
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.AbstractPollingInboundChannelAdapterParser;
|
||||
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||
import org.springframework.integration.ftp.FtpsRemoteFileSystemSynchronizingMessageSourceFactoryBean;
|
||||
import org.springframework.integration.ftp.inbound.FtpsRemoteFileSystemSynchronizingMessageSourceFactoryBean;
|
||||
|
||||
/**
|
||||
* Parser for the FTPS inbound-channel-adapter
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.springframework.core.io.Resource;
|
||||
import org.springframework.integration.MessagingException;
|
||||
import org.springframework.integration.file.synchronization.AbstractInboundRemoteFileSystemSychronizer;
|
||||
import org.springframework.integration.file.synchronization.AbstractInboundRemoteFileSystemSynchronizingMessageSource;
|
||||
import org.springframework.integration.ftp.FtpClientPool;
|
||||
import org.springframework.integration.ftp.client.FtpClientPool;
|
||||
import org.springframework.scheduling.Trigger;
|
||||
import org.springframework.scheduling.support.PeriodicTrigger;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -52,9 +52,9 @@ public class FtpInboundRemoteFileSystemSynchronizer extends AbstractInboundRemot
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link org.springframework.integration.ftp.FtpClientPool} that holds references to {@link org.apache.commons.net.ftp.FTPClient} instances
|
||||
* The {@link org.springframework.integration.ftp.client.FtpClientPool} that holds references to {@link org.apache.commons.net.ftp.FTPClient} instances
|
||||
*
|
||||
* @param clientPool the {@link org.springframework.integration.ftp.FtpClientPool}
|
||||
* @param clientPool the {@link org.springframework.integration.ftp.client.FtpClientPool}
|
||||
*/
|
||||
public void setClientPool(FtpClientPool clientPool) {
|
||||
this.clientPool = clientPool;
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.integration.ftp.inbound;
|
||||
import org.apache.commons.net.ftp.FTPFile;
|
||||
|
||||
import org.springframework.integration.file.synchronization.AbstractInboundRemoteFileSystemSynchronizingMessageSource;
|
||||
import org.springframework.integration.ftp.FtpClientPool;
|
||||
import org.springframework.integration.ftp.client.FtpClientPool;
|
||||
|
||||
/**
|
||||
* A {@link org.springframework.integration.core.MessageSource} implementation for FTP.
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.ftp;
|
||||
package org.springframework.integration.ftp.inbound;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -30,9 +30,10 @@ import org.springframework.core.io.ResourceEditor;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.integration.file.filters.CompositeFileListFilter;
|
||||
import org.springframework.integration.file.filters.FileListFilter;
|
||||
import org.springframework.integration.ftp.client.AbstractFtpClientFactory;
|
||||
import org.springframework.integration.ftp.client.DefaultFtpClientFactory;
|
||||
import org.springframework.integration.ftp.client.QueuedFtpClientPool;
|
||||
import org.springframework.integration.ftp.filters.FtpPatternMatchingFileListFilter;
|
||||
import org.springframework.integration.ftp.inbound.FtpInboundRemoteFileSystemSynchronizer;
|
||||
import org.springframework.integration.ftp.inbound.FtpInboundRemoteFileSystemSynchronizingMessageSource;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -44,57 +45,45 @@ import org.springframework.util.StringUtils;
|
||||
public class FtpRemoteFileSystemSynchronizingMessageSourceFactoryBean
|
||||
extends AbstractFactoryBean<FtpInboundRemoteFileSystemSynchronizingMessageSource> implements ResourceLoaderAware {
|
||||
|
||||
protected volatile String port;
|
||||
private volatile String autoCreateDirectories;
|
||||
|
||||
protected volatile String autoCreateDirectories;
|
||||
private volatile String filenamePattern;
|
||||
|
||||
protected volatile String filenamePattern;
|
||||
volatile String host;
|
||||
|
||||
protected volatile String username;
|
||||
volatile String port;
|
||||
|
||||
protected volatile String password;
|
||||
volatile String username;
|
||||
|
||||
protected volatile String host;
|
||||
volatile String password;
|
||||
|
||||
protected volatile String remoteDirectory;
|
||||
volatile String remoteDirectory;
|
||||
|
||||
protected volatile String localWorkingDirectory;
|
||||
volatile int clientMode = FTPClient.ACTIVE_LOCAL_DATA_CONNECTION_MODE;
|
||||
|
||||
protected volatile ResourceLoader resourceLoader;
|
||||
volatile int fileType = FTP.BINARY_FILE_TYPE;
|
||||
|
||||
protected volatile Resource localDirectoryResource;
|
||||
volatile String defaultFtpInboundFolderName = "ftpInbound";
|
||||
|
||||
protected volatile FileListFilter<FTPFile> filter;
|
||||
private volatile String localWorkingDirectory;
|
||||
|
||||
protected volatile int clientMode = FTPClient.ACTIVE_LOCAL_DATA_CONNECTION_MODE;
|
||||
private volatile Resource localDirectoryResource;
|
||||
|
||||
protected volatile int fileType = FTP.BINARY_FILE_TYPE;
|
||||
private volatile ResourceLoader resourceLoader;
|
||||
|
||||
private volatile FileListFilter<FTPFile> filter;
|
||||
|
||||
private volatile String autoDeleteRemoteFilesOnSync;
|
||||
|
||||
protected String defaultFtpInboundFolderName = "ftpInbound";
|
||||
|
||||
|
||||
public void setFileType(int fileType) {
|
||||
this.fileType = fileType;
|
||||
}
|
||||
|
||||
public void setAutoDeleteRemoteFilesOnSync(String autoDeleteRemoteFilesOnSync) {
|
||||
this.autoDeleteRemoteFilesOnSync = autoDeleteRemoteFilesOnSync;
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public void setPort(String port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public void setAutoCreateDirectories(String autoCreateDirectories) {
|
||||
this.autoCreateDirectories = autoCreateDirectories;
|
||||
}
|
||||
|
||||
public void setFilenamePattern(String filenamePattern) {
|
||||
this.filenamePattern = filenamePattern;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
@@ -103,8 +92,16 @@ public class FtpRemoteFileSystemSynchronizingMessageSourceFactoryBean
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
public void setFileType(int fileType) {
|
||||
this.fileType = fileType;
|
||||
}
|
||||
|
||||
public void setAutoCreateDirectories(String autoCreateDirectories) {
|
||||
this.autoCreateDirectories = autoCreateDirectories;
|
||||
}
|
||||
|
||||
public void setAutoDeleteRemoteFilesOnSync(String autoDeleteRemoteFilesOnSync) {
|
||||
this.autoDeleteRemoteFilesOnSync = autoDeleteRemoteFilesOnSync;
|
||||
}
|
||||
|
||||
public void setRemoteDirectory(String remoteDirectory) {
|
||||
@@ -115,12 +112,16 @@ public class FtpRemoteFileSystemSynchronizingMessageSourceFactoryBean
|
||||
this.localWorkingDirectory = localWorkingDirectory;
|
||||
}
|
||||
|
||||
public void setClientMode(int clientMode) {
|
||||
this.clientMode = clientMode;
|
||||
}
|
||||
|
||||
public void setFilter(FileListFilter<FTPFile> filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
public void setClientMode(int clientMode) {
|
||||
this.clientMode = clientMode;
|
||||
public void setFilenamePattern(String filenamePattern) {
|
||||
this.filenamePattern = filenamePattern;
|
||||
}
|
||||
|
||||
public void setResourceLoader(ResourceLoader resourceLoader) {
|
||||
@@ -132,54 +133,62 @@ public class FtpRemoteFileSystemSynchronizingMessageSourceFactoryBean
|
||||
return FtpInboundRemoteFileSystemSynchronizingMessageSource.class;
|
||||
}
|
||||
|
||||
private Resource fromText(String path) {
|
||||
private Resource resolveResource(String path) {
|
||||
ResourceEditor resourceEditor = new ResourceEditor(this.resourceLoader);
|
||||
resourceEditor.setAsText(path);
|
||||
return (Resource) resourceEditor.getValue();
|
||||
}
|
||||
|
||||
protected AbstractFtpClientFactory<?> defaultClientFactory() throws Exception {
|
||||
return ClientFactorySupport.ftpClientFactory(this.host,
|
||||
Integer.parseInt(this.port), this.remoteDirectory, this.username,
|
||||
this.password, this.clientMode, this.fileType);
|
||||
DefaultFtpClientFactory factory = new DefaultFtpClientFactory();
|
||||
factory.setHost(this.host);
|
||||
if (StringUtils.hasText(this.port)) {
|
||||
factory.setPort(Integer.parseInt(this.port));
|
||||
}
|
||||
factory.setUsername(this.username);
|
||||
factory.setPassword(this.password);
|
||||
factory.setRemoteWorkingDirectory(this.remoteDirectory);
|
||||
factory.setClientMode(this.clientMode);
|
||||
factory.setFileType(this.fileType);
|
||||
return factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FtpInboundRemoteFileSystemSynchronizingMessageSource createInstance() throws Exception {
|
||||
boolean autoCreatDirs = Boolean.parseBoolean(this.autoCreateDirectories);
|
||||
boolean ackRemoteDir = Boolean.parseBoolean(this.autoDeleteRemoteFilesOnSync);
|
||||
FtpInboundRemoteFileSystemSynchronizingMessageSource ftpRemoteFileSystemSynchronizingMessageSource =
|
||||
FtpInboundRemoteFileSystemSynchronizingMessageSource messageSource =
|
||||
new FtpInboundRemoteFileSystemSynchronizingMessageSource();
|
||||
ftpRemoteFileSystemSynchronizingMessageSource.setAutoCreateDirectories(autoCreatDirs);
|
||||
messageSource.setAutoCreateDirectories(autoCreatDirs);
|
||||
if (!StringUtils.hasText(this.localWorkingDirectory)) {
|
||||
File tmp = new File(SystemUtils.getJavaIoTmpDir(), defaultFtpInboundFolderName);
|
||||
File tmp = new File(SystemUtils.getJavaIoTmpDir(), this.defaultFtpInboundFolderName);
|
||||
this.localWorkingDirectory = "file://" + tmp.getAbsolutePath();
|
||||
}
|
||||
this.localDirectoryResource = this.fromText(this.localWorkingDirectory);
|
||||
CompositeFileListFilter<FTPFile> compositeFtpFileListFilter = new CompositeFileListFilter<FTPFile>();
|
||||
this.localDirectoryResource = this.resolveResource(this.localWorkingDirectory);
|
||||
CompositeFileListFilter<FTPFile> compositeFilter = new CompositeFileListFilter<FTPFile>();
|
||||
if (StringUtils.hasText(this.filenamePattern)) {
|
||||
FtpPatternMatchingFileListFilter ftpFilePatternMatchingFileListFilter =
|
||||
new FtpPatternMatchingFileListFilter(filenamePattern);
|
||||
compositeFtpFileListFilter.addFilter(ftpFilePatternMatchingFileListFilter);
|
||||
new FtpPatternMatchingFileListFilter(this.filenamePattern);
|
||||
compositeFilter.addFilter(ftpFilePatternMatchingFileListFilter);
|
||||
}
|
||||
if (this.filter != null) {
|
||||
compositeFtpFileListFilter.addFilter(this.filter);
|
||||
compositeFilter.addFilter(this.filter);
|
||||
}
|
||||
QueuedFtpClientPool queuedFtpClientPool = new QueuedFtpClientPool(15, defaultClientFactory());
|
||||
FtpInboundRemoteFileSystemSynchronizer ftpRemoteFileSystemSynchronizer = new FtpInboundRemoteFileSystemSynchronizer();
|
||||
ftpRemoteFileSystemSynchronizer.setClientPool(queuedFtpClientPool);
|
||||
ftpRemoteFileSystemSynchronizer.setLocalDirectory(this.localDirectoryResource);
|
||||
ftpRemoteFileSystemSynchronizer.setShouldDeleteSourceFile(ackRemoteDir);
|
||||
ftpRemoteFileSystemSynchronizer.setFilter(compositeFtpFileListFilter);
|
||||
ftpRemoteFileSystemSynchronizingMessageSource.setRemotePredicate(compositeFtpFileListFilter);
|
||||
ftpRemoteFileSystemSynchronizingMessageSource.setSynchronizer(ftpRemoteFileSystemSynchronizer);
|
||||
ftpRemoteFileSystemSynchronizingMessageSource.setClientPool(queuedFtpClientPool);
|
||||
ftpRemoteFileSystemSynchronizingMessageSource.setLocalDirectory(this.localDirectoryResource);
|
||||
ftpRemoteFileSystemSynchronizingMessageSource.setBeanFactory(this.getBeanFactory());
|
||||
ftpRemoteFileSystemSynchronizingMessageSource.setAutoStartup(true);
|
||||
ftpRemoteFileSystemSynchronizingMessageSource.afterPropertiesSet();
|
||||
ftpRemoteFileSystemSynchronizingMessageSource.start();
|
||||
return ftpRemoteFileSystemSynchronizingMessageSource;
|
||||
QueuedFtpClientPool queuedFtpClientPool = new QueuedFtpClientPool(15, this.defaultClientFactory());
|
||||
FtpInboundRemoteFileSystemSynchronizer synchronizer = new FtpInboundRemoteFileSystemSynchronizer();
|
||||
synchronizer.setClientPool(queuedFtpClientPool);
|
||||
synchronizer.setLocalDirectory(this.localDirectoryResource);
|
||||
synchronizer.setShouldDeleteSourceFile(ackRemoteDir);
|
||||
synchronizer.setFilter(compositeFilter);
|
||||
messageSource.setRemotePredicate(compositeFilter);
|
||||
messageSource.setSynchronizer(synchronizer);
|
||||
messageSource.setClientPool(queuedFtpClientPool);
|
||||
messageSource.setLocalDirectory(this.localDirectoryResource);
|
||||
messageSource.setBeanFactory(this.getBeanFactory());
|
||||
messageSource.setAutoStartup(true);
|
||||
messageSource.afterPropertiesSet();
|
||||
messageSource.start();
|
||||
return messageSource;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,10 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.ftp;
|
||||
package org.springframework.integration.ftp.inbound;
|
||||
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
|
||||
import org.springframework.integration.ftp.client.AbstractFtpClientFactory;
|
||||
import org.springframework.integration.ftp.client.DefaultFtpsClientFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.net.ssl.KeyManager;
|
||||
import javax.net.ssl.TrustManager;
|
||||
|
||||
@@ -111,14 +115,33 @@ public class FtpsRemoteFileSystemSynchronizingMessageSourceFactoryBean extends F
|
||||
}
|
||||
|
||||
protected AbstractFtpClientFactory<?> defaultClientFactory() throws Exception {
|
||||
DefaultFtpsClientFactory factory = ClientFactorySupport.ftpsClientFactory(this.host,
|
||||
Integer.parseInt(this.port), this.remoteDirectory,
|
||||
this.username, this.password, this.fileType, this.clientMode,
|
||||
this.prot, this.protocol, this.authValue, this.implicit,
|
||||
this.trustManager, this.keyManager, this.sessionCreation,
|
||||
this.useClientMode, this.wantsClientAuth, this.needClientAuth,
|
||||
this.cipherSuites);
|
||||
|
||||
DefaultFtpsClientFactory factory = new DefaultFtpsClientFactory();
|
||||
factory.setHost(this.host);
|
||||
if (StringUtils.hasText(this.port)) {
|
||||
factory.setPort(Integer.parseInt(this.port));
|
||||
}
|
||||
factory.setUsername(this.username);
|
||||
factory.setPassword(this.password);
|
||||
factory.setRemoteWorkingDirectory(this.remoteDirectory);
|
||||
factory.setFileType(this.fileType);
|
||||
factory.setClientMode(this.clientMode);
|
||||
factory.setCipherSuites(this.cipherSuites);
|
||||
factory.setAuthValue(this.authValue);
|
||||
factory.setTrustManager(this.trustManager);
|
||||
factory.setKeyManager(this.keyManager);
|
||||
factory.setNeedClientAuth(this.needClientAuth);
|
||||
factory.setWantsClientAuth(this.wantsClientAuth);
|
||||
factory.setSessionCreation(this.sessionCreation);
|
||||
factory.setUseClientMode(this.useClientMode);
|
||||
if (StringUtils.hasText(this.prot)) {
|
||||
factory.setProt(this.prot);
|
||||
}
|
||||
if (StringUtils.hasText(this.protocol)) {
|
||||
factory.setProtocol(this.protocol);
|
||||
}
|
||||
if (this.implicit != null) {
|
||||
factory.setImplicit(this.implicit);
|
||||
}
|
||||
return factory;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageDeliveryException;
|
||||
import org.springframework.integration.file.DefaultFileNameGenerator;
|
||||
import org.springframework.integration.file.FileNameGenerator;
|
||||
import org.springframework.integration.ftp.FtpClientPool;
|
||||
import org.springframework.integration.ftp.client.FtpClientPool;
|
||||
import org.springframework.integration.handler.AbstractMessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
@@ -14,12 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.ftp;
|
||||
package org.springframework.integration.ftp.outbound;
|
||||
|
||||
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.client.AbstractFtpClientFactory;
|
||||
import org.springframework.integration.ftp.client.DefaultFtpClientFactory;
|
||||
import org.springframework.integration.ftp.client.QueuedFtpClientPool;
|
||||
|
||||
/**
|
||||
* A factory bean implementation that handles constructing an outbound FTP
|
||||
@@ -91,9 +93,15 @@ public class FtpSendingMessageHandlerFactoryBean extends AbstractFactoryBean<Ftp
|
||||
}
|
||||
|
||||
protected AbstractFtpClientFactory<?> clientFactory() {
|
||||
return ClientFactorySupport.ftpClientFactory(this.host, this.port,
|
||||
this.remoteDirectory, this.username, this.password,
|
||||
this.clientMode, this.fileType);
|
||||
DefaultFtpClientFactory defaultFtpClientFactory = new DefaultFtpClientFactory();
|
||||
defaultFtpClientFactory.setHost(this.host);
|
||||
defaultFtpClientFactory.setPort(this.port);
|
||||
defaultFtpClientFactory.setUsername(this.username);
|
||||
defaultFtpClientFactory.setPassword(this.password);
|
||||
defaultFtpClientFactory.setRemoteWorkingDirectory(this.remoteDirectory);
|
||||
defaultFtpClientFactory.setClientMode(this.clientMode);
|
||||
defaultFtpClientFactory.setFileType(this.fileType);
|
||||
return defaultFtpClientFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -14,11 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.ftp;
|
||||
package org.springframework.integration.ftp.outbound;
|
||||
|
||||
import javax.net.ssl.KeyManager;
|
||||
import javax.net.ssl.TrustManager;
|
||||
|
||||
import org.springframework.integration.ftp.client.AbstractFtpClientFactory;
|
||||
import org.springframework.integration.ftp.client.DefaultFtpsClientFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Sends files to a remote FTPS file system. Based heavily on {@link org.springframework.integration.ftp.outbound.FtpSendingMessageHandler}
|
||||
*
|
||||
@@ -28,7 +32,7 @@ import javax.net.ssl.TrustManager;
|
||||
public class FtpsSendingMessageHandlerFactoryBean extends FtpSendingMessageHandlerFactoryBean {
|
||||
|
||||
/**
|
||||
* Sets whether the connection is implicit. Local testing reveals this to be a good choice.
|
||||
* Sets whether the connection is implicit. Default is FALSE.
|
||||
*/
|
||||
protected volatile Boolean implicit = Boolean.FALSE;
|
||||
|
||||
@@ -42,23 +46,23 @@ public class FtpsSendingMessageHandlerFactoryBean extends FtpSendingMessageHandl
|
||||
*/
|
||||
protected volatile String prot;
|
||||
|
||||
private KeyManager keyManager;
|
||||
private volatile KeyManager keyManager;
|
||||
|
||||
private TrustManager trustManager;
|
||||
private volatile TrustManager trustManager;
|
||||
|
||||
protected volatile String authValue;
|
||||
|
||||
private Boolean sessionCreation;
|
||||
private volatile Boolean sessionCreation;
|
||||
|
||||
private Boolean useClientMode;
|
||||
private volatile Boolean useClientMode;
|
||||
|
||||
private Boolean needClientAuth;
|
||||
private volatile Boolean needClientAuth;
|
||||
|
||||
private Boolean wantsClientAuth;
|
||||
private volatile Boolean wantsClientAuth;
|
||||
|
||||
private String[] cipherSuites;
|
||||
private volatile String[] cipherSuites;
|
||||
|
||||
private int fileType;
|
||||
private volatile int fileType;
|
||||
|
||||
|
||||
public void setImplicit(Boolean implicit) {
|
||||
@@ -111,13 +115,31 @@ public class FtpsSendingMessageHandlerFactoryBean extends FtpSendingMessageHandl
|
||||
|
||||
@Override
|
||||
protected AbstractFtpClientFactory<?> clientFactory() {
|
||||
DefaultFtpsClientFactory factory = ClientFactorySupport.ftpsClientFactory(this.host,
|
||||
(this.port), this.remoteDirectory, this.username,
|
||||
this.password, this.fileType, this.clientMode, this.prot,
|
||||
this.protocol, this.authValue, this.implicit,
|
||||
this.trustManager, this.keyManager, this.sessionCreation,
|
||||
this.useClientMode, this.wantsClientAuth, this.needClientAuth,
|
||||
this.cipherSuites);
|
||||
DefaultFtpsClientFactory factory = new DefaultFtpsClientFactory();
|
||||
factory.setHost(this.host);
|
||||
factory.setPort(this.port);
|
||||
factory.setUsername(this.username);
|
||||
factory.setPassword(this.password);
|
||||
factory.setRemoteWorkingDirectory(this.remoteDirectory);
|
||||
factory.setFileType(this.fileType);
|
||||
factory.setClientMode(this.clientMode);
|
||||
factory.setCipherSuites(this.cipherSuites);
|
||||
factory.setAuthValue(this.authValue);
|
||||
factory.setTrustManager(this.trustManager);
|
||||
factory.setKeyManager(this.keyManager);
|
||||
factory.setNeedClientAuth(this.needClientAuth);
|
||||
factory.setWantsClientAuth(this.wantsClientAuth);
|
||||
factory.setSessionCreation(this.sessionCreation);
|
||||
factory.setUseClientMode(this.useClientMode);
|
||||
if (StringUtils.hasText(this.prot)) {
|
||||
factory.setProt(this.prot);
|
||||
}
|
||||
if (StringUtils.hasText(this.protocol)) {
|
||||
factory.setProtocol(this.protocol);
|
||||
}
|
||||
if (this.implicit != null) {
|
||||
factory.setImplicit(this.implicit);
|
||||
}
|
||||
return factory;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user