INT-1591 removing the FileNameExtractor strategy in favor of concrete implementations of AbstractPatternMatchingFileListFilter

This commit is contained in:
Mark Fisher
2010-11-08 18:32:57 -05:00
parent 2a8994d7b6
commit 23c8c28d0c
13 changed files with 128 additions and 161 deletions

View File

@@ -16,18 +16,30 @@
package org.springframework.integration.sftp;
import org.springframework.integration.file.entries.EntryNameExtractor;
import java.util.regex.Pattern;
import org.springframework.integration.file.filters.AbstractPatternMatchingFileListFilter;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.ChannelSftp.LsEntry;
/**
* Stratgy for naming a {@link com.jcraft.jsch.ChannelSftp.LsEntry} instance.
*
* @author Josh Long
* @author Mark Fisher
* @since 2.0
*/
public class SftpEntryNameExtractor implements EntryNameExtractor<ChannelSftp.LsEntry> {
public class SftpPatternMatchingFileListFilter extends AbstractPatternMatchingFileListFilter<ChannelSftp.LsEntry> {
public String getName(ChannelSftp.LsEntry entry) {
public SftpPatternMatchingFileListFilter(String pattern) {
super(pattern);
}
public SftpPatternMatchingFileListFilter(Pattern pattern) {
super(pattern);
}
@Override
protected String getFilename(LsEntry entry) {
return entry.getFilename();
}

View File

@@ -27,9 +27,8 @@ 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.file.filters.PatternMatchingFileListFilter;
import org.springframework.integration.sftp.QueuedSftpSessionPool;
import org.springframework.integration.sftp.SftpEntryNameExtractor;
import org.springframework.integration.sftp.SftpPatternMatchingFileListFilter;
import org.springframework.integration.sftp.SftpSessionFactory;
import org.springframework.integration.sftp.impl.SftpInboundRemoteFileSystemSynchronizer;
import org.springframework.integration.sftp.impl.SftpInboundRemoteFileSystemSynchronizingMessageSource;
@@ -171,12 +170,11 @@ public class SftpRemoteFileSystemSynchronizingMessageSourceFactoryBean
this.localDirectoryResource = this.resourceFromString(localDirectoryPath);
// remote predicates
SftpEntryNameExtractor sftpEntryNameExtractor = new SftpEntryNameExtractor();
CompositeFileListFilter<ChannelSftp.LsEntry> compositeFtpFileListFilter = new CompositeFileListFilter<ChannelSftp.LsEntry>();
if (StringUtils.hasText(this.filenamePattern)) {
PatternMatchingFileListFilter<ChannelSftp.LsEntry> ftpFilePatternMatchingEntryListFilter =
new PatternMatchingFileListFilter<ChannelSftp.LsEntry>(sftpEntryNameExtractor, filenamePattern);
compositeFtpFileListFilter.addFilter(ftpFilePatternMatchingEntryListFilter);
SftpPatternMatchingFileListFilter sftpFilePatternMatchingEntryListFilter =
new SftpPatternMatchingFileListFilter(filenamePattern);
compositeFtpFileListFilter.addFilter(sftpFilePatternMatchingEntryListFilter);
}
if (this.filter != null) {
compositeFtpFileListFilter.addFilter(this.filter);