I can be so forgetful sometimes! I've just changed *SFTP* -> *Sftp* and *FTP* to *Ftp*. Looks *much* better now and feels more like the Spring I know and love.

This commit is contained in:
Josh Long
2010-08-18 05:49:07 +00:00
parent 006c826995
commit b1571e2767
23 changed files with 92 additions and 92 deletions

View File

@@ -11,7 +11,7 @@ import java.util.List;
*
* @author Josh Long
*/
public abstract class AbstractFTPFileListFilter implements FTPFileListFilter {
public abstract class AbstractFtpFileListFilter implements FtpFileListFilter {
/**
* {@inheritDoc}
*/

View File

@@ -11,17 +11,17 @@ import java.util.*;
*
* @author Josh Long
*/
public class CompositeFTPFileListFilter implements FTPFileListFilter {
private Set<FTPFileListFilter> filters;
public class CompositeFtpFileListFilter implements FtpFileListFilter {
private Set<FtpFileListFilter> filters;
public CompositeFTPFileListFilter(FTPFileListFilter... ftpFileListFilter) {
this.filters = new LinkedHashSet<FTPFileListFilter>(Arrays.asList(ftpFileListFilter));
public CompositeFtpFileListFilter(FtpFileListFilter... ftpFileListFilter) {
this.filters = new LinkedHashSet<FtpFileListFilter>(Arrays.asList(ftpFileListFilter));
}
public CompositeFTPFileListFilter(Collection<FTPFileListFilter> ftpFileListFilter) {
this.filters = new LinkedHashSet<FTPFileListFilter>(ftpFileListFilter);
public CompositeFtpFileListFilter(Collection<FtpFileListFilter> ftpFileListFilter) {
this.filters = new LinkedHashSet<FtpFileListFilter>(ftpFileListFilter);
}
public void addFilter( FTPFileListFilter ftpFileListFilter ) {
public void addFilter( FtpFileListFilter ftpFileListFilter ) {
this.filters.add(ftpFileListFilter);
}
public List<FTPFile> filterFiles(FTPFile[] files) {
@@ -29,7 +29,7 @@ public class CompositeFTPFileListFilter implements FTPFileListFilter {
List<FTPFile> leftOver = Arrays.asList(files);
for (FTPFileListFilter ff : this.filters)
for (FtpFileListFilter ff : this.filters)
leftOver = ff.filterFiles(leftOver.toArray(new FTPFile[leftOver.size()]));
return leftOver;

View File

@@ -30,12 +30,12 @@ import java.net.SocketException;
/**
* Default implementation of FTPClientFactory.
* Default implementation of FtpClientFactory.
*
* @author iwein
*/
public class DefaultFTPClientFactory implements FTPClientFactory {
private static final Log logger = LogFactory.getLog(FTPClientFactory.class);
public class DefaultFtpClientFactory implements FTPClientFactory {
private static final Log logger = LogFactory.getLog(FtpClientFactory.class);
private static final String DEFAULT_REMOTE_WORKING_DIRECTORY = "/";
private FTPClientConfig config;
private String username;

View File

@@ -27,7 +27,7 @@ import java.util.regex.Pattern;
*
* @author Josh Long
*/
public class FTPMessageSourceFactoryBean extends AbstractFactoryBean<FTPFileSource> implements ResourceLoaderAware, ApplicationContextAware {
public class FTPMessageSourceFactoryBean extends AbstractFactoryBean<FtpFileSource> implements ResourceLoaderAware, ApplicationContextAware {
private int port;
private boolean autoCreateDirectories;
private String filenamePattern;
@@ -38,7 +38,7 @@ public class FTPMessageSourceFactoryBean extends AbstractFactoryBean<FTPFileSour
private String localWorkingDirectory;
private ApplicationContext applicationContext;
private Resource localDirectoryResource;
private FTPInboundSynchronizer ftpInboundSynchronizer;
private FtpInboundSynchronizer ftpInboundSynchronizer;
private TaskScheduler taskScheduler;
private ResourceLoader resourceLoader;
private FileReadingMessageSource fileReadingMessageSource;
@@ -47,7 +47,7 @@ public class FTPMessageSourceFactoryBean extends AbstractFactoryBean<FTPFileSour
/**
* Used to teach the FTP adapter what files you are interested in receiving
*/
private FTPFileListFilter filter;
private FtpFileListFilter filter;
public void setFilenamePattern(String filenamePattern) {
this.filenamePattern = filenamePattern;
@@ -90,20 +90,20 @@ public class FTPMessageSourceFactoryBean extends AbstractFactoryBean<FTPFileSour
this.resourceLoader = resourceLoader;
}
public Class<?extends FTPFileSource> getObjectType() {
return FTPFileSource.class;
public Class<?extends FtpFileSource> getObjectType() {
return FtpFileSource.class;
}
public void setClientMode(int clientMode) {
this.clientMode = clientMode;
}
public void setFilter(FTPFileListFilter filter) {
public void setFilter(FtpFileListFilter filter) {
this.filter = filter;
}
@Override
protected FTPFileSource createInstance() throws Exception {
protected FtpFileSource createInstance() throws Exception {
// setup local dir
if (!StringUtils.hasText(this.localWorkingDirectory)) {
File tmp = SystemUtils.getJavaIoTmpDir();
@@ -118,21 +118,21 @@ public class FTPMessageSourceFactoryBean extends AbstractFactoryBean<FTPFileSour
this.localDirectoryResource = (Resource) resourceEditor.getValue();
fileReadingMessageSource = new FileReadingMessageSource();
this.ftpInboundSynchronizer = new FTPInboundSynchronizer();
this.ftpInboundSynchronizer = new FtpInboundSynchronizer();
CompositeFTPFileListFilter compositeFTPFileListFilter = new CompositeFTPFileListFilter();
CompositeFtpFileListFilter compositeFtpFileListFilter = new CompositeFtpFileListFilter();
if (StringUtils.hasText(this.filenamePattern)) {
PatternMatchingFTPFileListFilter patternMatchingFTPFileListFilter = new PatternMatchingFTPFileListFilter();
PatternMatchingFtpFileListFilter patternMatchingFTPFileListFilter = new PatternMatchingFtpFileListFilter();
patternMatchingFTPFileListFilter.setPattern(Pattern.compile(this.filenamePattern));
compositeFTPFileListFilter.addFilter(patternMatchingFTPFileListFilter);
compositeFtpFileListFilter.addFilter(patternMatchingFTPFileListFilter);
}
if (this.filter != null) {
compositeFTPFileListFilter.addFilter(this.filter);
compositeFtpFileListFilter.addFilter(this.filter);
}
this.ftpInboundSynchronizer.setFilter(compositeFTPFileListFilter);
this.ftpInboundSynchronizer.setFilter(compositeFtpFileListFilter);
if (this.taskScheduler == null) {
Map<String, TaskScheduler> tss = null;
@@ -155,17 +155,17 @@ public class FTPMessageSourceFactoryBean extends AbstractFactoryBean<FTPFileSour
this.taskScheduler = threadPoolTaskScheduler;
}
DefaultFTPClientFactory defaultFTPClientFactory = new DefaultFTPClientFactory();
defaultFTPClientFactory.setHost(this.host);
defaultFTPClientFactory.setPassword(this.password);
defaultFTPClientFactory.setPort(this.port);
defaultFTPClientFactory.setRemoteWorkingDirectory(this.remoteDirectory);
defaultFTPClientFactory.setUsername(this.username);
defaultFTPClientFactory.setClientMode(this.clientMode);
DefaultFtpClientFactory defaultFtpClientFactory = new DefaultFtpClientFactory();
defaultFtpClientFactory.setHost(this.host);
defaultFtpClientFactory.setPassword(this.password);
defaultFtpClientFactory.setPort(this.port);
defaultFtpClientFactory.setRemoteWorkingDirectory(this.remoteDirectory);
defaultFtpClientFactory.setUsername(this.username);
defaultFtpClientFactory.setClientMode(this.clientMode);
QueuedFTPClientPool queuedFTPClientPool = new QueuedFTPClientPool(15, defaultFTPClientFactory);
QueuedFtpClientPool queuedFtpClientPool = new QueuedFtpClientPool(15, defaultFtpClientFactory);
this.ftpInboundSynchronizer.setClientPool(queuedFTPClientPool);
this.ftpInboundSynchronizer.setClientPool(queuedFtpClientPool);
this.ftpInboundSynchronizer.setLocalDirectory(this.localDirectoryResource);
this.ftpInboundSynchronizer.setTaskScheduler(this.taskScheduler);
assert this.localDirectoryResource != null : "the 'localDirectoryResource' can't be null at this point";
@@ -184,8 +184,8 @@ public class FTPMessageSourceFactoryBean extends AbstractFactoryBean<FTPFileSour
this.ftpInboundSynchronizer.afterPropertiesSet();
FTPFileSource ftpFileSource = new FTPFileSource(this.fileReadingMessageSource, this.ftpInboundSynchronizer);
ftpFileSource.setClientPool(queuedFTPClientPool);
FtpFileSource ftpFileSource = new FtpFileSource(this.fileReadingMessageSource, this.ftpInboundSynchronizer);
ftpFileSource.setClientPool(queuedFtpClientPool);
ftpFileSource.setLocalWorkingDirectory(this.localDirectoryResource);
ftpFileSource.setSynchronizer(this.ftpInboundSynchronizer);
ftpFileSource.setTaskScheduler(this.taskScheduler);

View File

@@ -13,7 +13,7 @@ import org.springframework.core.io.ResourceLoader;
*
* @author Josh Long
*/
public class FTPSendingMessageHandlerFactoryBean extends AbstractFactoryBean<FTPSendingMessageHandler> implements ResourceLoaderAware, ApplicationContextAware {
public class FTPSendingMessageHandlerFactoryBean extends AbstractFactoryBean<FtpSendingMessageHandler> implements ResourceLoaderAware, ApplicationContextAware {
private int port;
private String username;
private String password;
@@ -39,26 +39,26 @@ public class FTPSendingMessageHandlerFactoryBean extends AbstractFactoryBean<FTP
}
@Override
public Class<?extends FTPSendingMessageHandler> getObjectType() {
return FTPSendingMessageHandler.class;
public Class<?extends FtpSendingMessageHandler> getObjectType() {
return FtpSendingMessageHandler.class;
}
@Override
protected FTPSendingMessageHandler createInstance()
protected FtpSendingMessageHandler createInstance()
throws Exception {
// the dependencies for the outbound-adapter are much simpler
// they only require an instance of the pool
DefaultFTPClientFactory defaultFTPClientFactory = new DefaultFTPClientFactory();
defaultFTPClientFactory.setHost(this.host);
defaultFTPClientFactory.setPassword(this.password);
defaultFTPClientFactory.setPort(this.port);
defaultFTPClientFactory.setRemoteWorkingDirectory(this.remoteDirectory);
defaultFTPClientFactory.setUsername(this.username);
defaultFTPClientFactory.setClientMode(this.clientMode);
DefaultFtpClientFactory defaultFtpClientFactory = new DefaultFtpClientFactory();
defaultFtpClientFactory.setHost(this.host);
defaultFtpClientFactory.setPassword(this.password);
defaultFtpClientFactory.setPort(this.port);
defaultFtpClientFactory.setRemoteWorkingDirectory(this.remoteDirectory);
defaultFtpClientFactory.setUsername(this.username);
defaultFtpClientFactory.setClientMode(this.clientMode);
QueuedFTPClientPool queuedFTPClientPool = new QueuedFTPClientPool(15, defaultFTPClientFactory);
QueuedFtpClientPool queuedFtpClientPool = new QueuedFtpClientPool(15, defaultFtpClientFactory);
FTPSendingMessageHandler ftpSendingMessageHandler = new FTPSendingMessageHandler(queuedFTPClientPool);
FtpSendingMessageHandler ftpSendingMessageHandler = new FtpSendingMessageHandler(queuedFtpClientPool);
ftpSendingMessageHandler.afterPropertiesSet();
return ftpSendingMessageHandler;

View File

@@ -25,7 +25,7 @@ import java.io.IOException;
*
* @author Iwein Fuld
*/
public interface FTPClientFactory {
public interface FtpClientFactory {
/**
* @return Fully configured and connected FTPClient. Never <code>null</code>.
* @throws IOException thrown when a networking IO subsystem error occurs

View File

@@ -24,7 +24,7 @@ import org.apache.commons.net.ftp.FTPClient;
*
* @author Iwein Fuld
*/
public interface FTPClientPool extends FTPClientFactory {
public interface FtpClientPool extends FtpClientFactory {
/**
* Releases the client back to the pool. When calling this method the caller
* is no longer responsible for the connection. The pool is free to do with

View File

@@ -9,6 +9,6 @@ import java.util.List;
*
* @author Josh Long
*/
public interface FTPFileListFilter {
public interface FtpFileListFilter {
List<FTPFile> filterFiles (FTPFile [] files);
}

View File

@@ -37,19 +37,19 @@ import java.util.regex.Pattern;
*
* @author Iwein Fuld
*/
public class FTPFileSource implements MessageSource<File>, InitializingBean, Lifecycle {
public class FtpFileSource implements MessageSource<File>, InitializingBean, Lifecycle {
private FileReadingMessageSource fileSource;
private FTPInboundSynchronizer synchronizer;
private FtpInboundSynchronizer synchronizer;
public FTPFileSource() {
this(new FileReadingMessageSource(), new FTPInboundSynchronizer());
public FtpFileSource() {
this(new FileReadingMessageSource(), new FtpInboundSynchronizer());
}
public FTPFileSource(FileReadingMessageSource fileSource, FTPInboundSynchronizer synchronizer) {
public FtpFileSource(FileReadingMessageSource fileSource, FtpInboundSynchronizer synchronizer) {
this.fileSource = fileSource;
this.synchronizer = synchronizer;
Pattern completePattern = Pattern.compile("^.*(?<!" + FTPInboundSynchronizer.INCOMPLETE_EXTENSION + ")$");
Pattern completePattern = Pattern.compile("^.*(?<!" + FtpInboundSynchronizer.INCOMPLETE_EXTENSION + ")$");
fileSource.setFilter(new CompositeFileListFilter(new AcceptOnceFileListFilter(), new PatternMatchingFileListFilter(completePattern)));
}
@@ -57,7 +57,7 @@ public class FTPFileSource implements MessageSource<File>, InitializingBean, Lif
this.fileSource = fileSource;
}
public void setSynchronizer(FTPInboundSynchronizer synchronizer) {
public void setSynchronizer(FtpInboundSynchronizer synchronizer) {
this.synchronizer = synchronizer;
}
@@ -78,7 +78,7 @@ public class FTPFileSource implements MessageSource<File>, InitializingBean, Lif
synchronizer.setTaskScheduler(scheduler);
}
public void setClientPool(FTPClientPool pool) {
public void setClientPool(FtpClientPool pool) {
synchronizer.setClientPool(pool);
}

View File

@@ -39,29 +39,29 @@ import java.util.concurrent.ScheduledFuture;
/**
* <code>FTPInboundSynchronizer</code> will keep a local directory in sync with a remote Ftp directory.
* <code>FtpInboundSynchronizer</code> will keep a local directory in sync with a remote Ftp directory.
* It will NOT move new files put into the local directory to the remote server.
*
* @author Iwein Fuld
*/
public class FTPInboundSynchronizer implements InitializingBean, Lifecycle {
private static final Log logger = LogFactory.getLog(FTPInboundSynchronizer.class);
public class FtpInboundSynchronizer implements InitializingBean, Lifecycle {
private static final Log logger = LogFactory.getLog(FtpInboundSynchronizer.class);
static final String INCOMPLETE_EXTENSION = ".INCOMPLETE";
private static final long DEFAULT_REFRESH_RATE = 10000;
private volatile TaskScheduler taskScheduler;
private volatile Trigger trigger = new PeriodicTrigger(DEFAULT_REFRESH_RATE);
private volatile FTPClientPool clientPool;
private volatile FtpClientPool clientPool;
private volatile Resource localDirectory;
private boolean running = false;
private ScheduledFuture<?> scheduledFuture;
private FTPFileListFilter filter;
private FTPFileListFilter acceptAllFTPFileListFilter = new FTPFileListFilter() {
private FtpFileListFilter filter;
private FtpFileListFilter acceptAllFtpFileListFilter = new FtpFileListFilter() {
public List<FTPFile> filterFiles(FTPFile[] files) {
return Arrays.asList(files);
}
};
public void setFilter(FTPFileListFilter filter) {
public void setFilter(FtpFileListFilter filter) {
this.filter = filter;
}
@@ -77,7 +77,7 @@ public class FTPInboundSynchronizer implements InitializingBean, Lifecycle {
this.localDirectory = localDirectory;
}
public void setClientPool(FTPClientPool pool) {
public void setClientPool(FtpClientPool pool) {
clientPool = pool;
}
@@ -85,14 +85,14 @@ public class FTPInboundSynchronizer implements InitializingBean, Lifecycle {
Assert.notNull(localDirectory, "'localDirectory' is required.");
if (this.filter == null) {
this.filter = acceptAllFTPFileListFilter;
this.filter = acceptAllFtpFileListFilter;
}
}
private void synchronize() {
try {
FTPClient client = this.clientPool.getClient();
Assert.state(client != null, FTPClientPool.class.getSimpleName() + " returned 'null' client this most likely a bug in the pool implementation.");
Assert.state(client != null, FtpClientPool.class.getSimpleName() + " returned 'null' client this most likely a bug in the pool implementation.");
Collection<FTPFile> fileList = this.filter.filterFiles(client.listFiles());

View File

@@ -35,17 +35,17 @@ import java.net.SocketException;
* @author Iwein Fuld
* @author Mark Fisher
*/
public class FTPSendingMessageHandler implements MessageHandler, InitializingBean {
private FTPClientPool ftpClientPool;
public class FtpSendingMessageHandler implements MessageHandler, InitializingBean {
private FtpClientPool ftpClientPool;
public FTPSendingMessageHandler() {
public FtpSendingMessageHandler() {
}
public FTPSendingMessageHandler(FTPClientPool ftpClientPool) {
public FtpSendingMessageHandler(FtpClientPool ftpClientPool) {
this.ftpClientPool = ftpClientPool;
}
public void setFtpClientPool(FTPClientPool ftpClientPool) {
public void setFtpClientPool(FtpClientPool ftpClientPool) {
this.ftpClientPool = ftpClientPool;
}
@@ -98,7 +98,7 @@ public class FTPSendingMessageHandler implements MessageHandler, InitializingBea
private FTPClient getFtpClient() throws SocketException, IOException {
FTPClient client;
client = this.ftpClientPool.getClient();
Assert.state(client != null, FTPClientPool.class.getSimpleName() + " returned 'null' client this most likely a bug in the pool implementation.");
Assert.state(client != null, FtpClientPool.class.getSimpleName() + " returned 'null' client this most likely a bug in the pool implementation.");
return client;
}

View File

@@ -17,7 +17,7 @@ import java.util.regex.Pattern;
*
* @author Josh Long
*/
public class PatternMatchingFTPFileListFilter extends AbstractFTPFileListFilter implements InitializingBean {
public class PatternMatchingFtpFileListFilter extends AbstractFtpFileListFilter implements InitializingBean {
private Log logger = LogFactory.getLog(getClass());

View File

@@ -27,7 +27,7 @@ import java.util.concurrent.ArrayBlockingQueue;
/**
* FTPClientPool implementation based on a Queue. This implementation has a
* FtpClientPool implementation based on a Queue. This implementation has a
* default pool size of 5, but this is configurable with a constructor argument.
* <p>
* This implementation pools released clients, but gives no guarantee to the
@@ -35,20 +35,20 @@ import java.util.concurrent.ArrayBlockingQueue;
*
* @author Iwein Fuld
*/
public class QueuedFTPClientPool implements FTPClientPool {
private static final Log log = LogFactory.getLog(QueuedFTPClientPool.class);
public class QueuedFtpClientPool implements FtpClientPool {
private static final Log log = LogFactory.getLog(QueuedFtpClientPool.class);
private static final int DEFAULT_POOL_SIZE = 5;
private final Queue<FTPClient> pool;
private final FTPClientFactory factory;
private final FtpClientFactory factory;
public QueuedFTPClientPool(FTPClientFactory factory) {
public QueuedFtpClientPool(FtpClientFactory factory) {
this(DEFAULT_POOL_SIZE, factory);
}
/**
* @param maxPoolSize the maximum size of the pool
*/
public QueuedFTPClientPool(int maxPoolSize, FTPClientFactory factory) {
public QueuedFtpClientPool(int maxPoolSize, FtpClientFactory factory) {
Assert.notNull(factory);
this.factory = factory;
pool = new ArrayBlockingQueue<FTPClient>(maxPoolSize);

View File

@@ -35,7 +35,7 @@ import java.util.Map;
* @author Josh Long (*heavily* influenced by the good done by iwein before)
*/
@SuppressWarnings("unused")
public class FTPNamespaceHandler extends NamespaceHandlerSupport {
public class FtpNamespaceHandler extends NamespaceHandlerSupport {
private static final String PACKAGE_NAME = "org.springframework.integration.ftp";
static private Map<String, Integer> CLIENT_MODES = new HashMap<String, Integer>();

View File

@@ -1 +1 @@
http\://www.springframework.org/schema/integration/ftp=org.springframework.integration.ftp.config.FTPNamespaceHandler
http\://www.springframework.org/schema/integration/ftp=org.springframework.integration.ftp.config.FtpNamespaceHandler

View File

@@ -138,7 +138,7 @@
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.integration.ftp.FTPFileListFilter"/>
<tool:expected-type type="org.springframework.integration.ftp.FtpFileListFilter"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>

View File

@@ -14,7 +14,7 @@ import java.io.File;
* @author Josh Long
*/
public class InboundFTPFileServiceActivator {
public class InboundFtpFileServiceActivator {
@ServiceActivator
public void onNewRemoteFTPFile(Message<File> file)

View File

@@ -9,7 +9,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*
* @author Josh Long
*/
public class OutboundFTPExample {
public class OutboundFtpExample {
public static void main(String [] args ) throws Throwable {
ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("outbound-ftp-context.xml");
}

View File

@@ -13,7 +13,7 @@
ignore-unresolvable="true"/>
<bean class="org.springframework.integration.ftp.PatternMatchingFTPFileListFilter" id="patternMatchingFTPFileListFilter">
<bean class="org.springframework.integration.ftp.PatternMatchingFtpFileListFilter" id="patternMatchingFTPFileListFilter">
<property name="patternExpression" value=".*?jpg"/>
</bean>
@@ -31,7 +31,7 @@
<int:channel id="ftpIn"/>
<bean id="inboundFTPFileServiceActivator"
class="org.springframework.integration.ftp.InboundFTPFileServiceActivator"/>
class="org.springframework.integration.ftp.InboundFtpFileServiceActivator"/>
<int:service-activator input-channel="ftpIn" ref="inboundFTPFileServiceActivator"/>

View File

@@ -98,7 +98,7 @@
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.integration.ftp.FTPFileListFilter"/>
<tool:expected-type type="org.springframework.integration.ftp.FtpFileListFilter"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>

View File

@@ -8,7 +8,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestInboundSftp {
static public void main(String [] args) throws Throwable {
ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("TestInboundSFTP.xml");
ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("TestInboundSftp.xml");
classPathXmlApplicationContext.start();
}
}