From 1f5dfff2e548b74eba13203461e2ef7c82d978fb Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Thu, 18 Nov 2010 22:46:01 -0500 Subject: [PATCH] polishing --- .../sftp/inbound/SftpInboundSynchronizer.java | 8 +++-- ...SftpInboundSynchronizingMessageSource.java | 32 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundSynchronizer.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundSynchronizer.java index 8796e54de6..53fdd4f71a 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundSynchronizer.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundSynchronizer.java @@ -36,7 +36,7 @@ import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.SftpATTRS; /** - * Gandles the synchronization between a remote SFTP endpoint and a local mount. + * Handles the synchronization between a remote SFTP directory and a local mount. * * @author Josh Long * @author Oleg Zhurakousky @@ -55,12 +55,14 @@ public class SftpInboundSynchronizer extends AbstractInboundRemoteFileSystemSych * the pool of {@link org.springframework.integration.sftp.session.SftpSessionPool} SFTP sessions */ private final SftpSessionPool sessionPool; - - public SftpInboundSynchronizer(SftpSessionPool sessionPool){ + + + public SftpInboundSynchronizer(SftpSessionPool sessionPool) { Assert.notNull(sessionPool, "'sessionPool' must not be null"); this.sessionPool = sessionPool; } + public void setAutoCreateDirectories(boolean autoCreateDirectories) { this.autoCreateDirectories = autoCreateDirectories; } diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundSynchronizingMessageSource.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundSynchronizingMessageSource.java index 8fad28e563..f2be0b3976 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundSynchronizingMessageSource.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/inbound/SftpInboundSynchronizingMessageSource.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.sftp.inbound; import java.io.File; @@ -27,7 +28,6 @@ import org.springframework.integration.sftp.filters.SftpPatternMatchingFileListF import com.jcraft.jsch.ChannelSftp; - /** * a {@link org.springframework.integration.core.MessageSource} implementation for SFTP * @@ -35,27 +35,28 @@ import com.jcraft.jsch.ChannelSftp; * @author Oleg Zhurakousky * @since 2.0 */ -public class SftpInboundSynchronizingMessageSource extends - AbstractInboundRemoteFileSystemSynchronizingMessageSource { +public class SftpInboundSynchronizingMessageSource + extends AbstractInboundRemoteFileSystemSynchronizingMessageSource { private volatile Pattern filenamePattern; + public void setFilenamePattern(Pattern filenamePattern) { this.filenamePattern = filenamePattern; } - public String getComponentType(){ + public String getComponentType() { return "sftp:inbound-channel-adapter"; } - + public Message receive() { /* - * Basically keep polling from the file source untill null, - * then attempt to sync up with remote directory which should populate the file source - * if anything is there and poll on file source again and if its still null then return it. + * Poll from the file source. If the result is not null, return it. + * If the result is null, attempt to sync up with remote directory to populate the file source. + * Then, poll on the file source again and return the result, whether or not it is null. */ Message message = this.fileSource.receive(); - if (message == null){ + if (message == null) { this.synchronizer.syncRemoteToLocalFileSystem(); message = this.fileSource.receive(); } @@ -76,9 +77,7 @@ public class SftpInboundSynchronizingMessageSource extends throw new FileNotFoundException(this.localDirectory.getFilename()); } } - /** - * Forwards files once they ultimately appear in the {@link #localDirectory}. - */ + // Forwards files once they appear in the {@link #localDirectory}. this.fileSource = new FileReadingMessageSource(); this.fileSource.setDirectory(this.localDirectory.getFile()); this.fileSource.afterPropertiesSet(); @@ -91,12 +90,11 @@ public class SftpInboundSynchronizingMessageSource extends + this.getComponentType(), e); } - if (filenamePattern != null) { - SftpPatternMatchingFileListFilter sftpFilePatternMatchingEntryListFilter = - new SftpPatternMatchingFileListFilter(filenamePattern); - //TODO refactor the design so values don't need to be duplicated - this.synchronizer.setFilter(sftpFilePatternMatchingEntryListFilter); + if (this.filenamePattern != null) { + SftpPatternMatchingFileListFilter filter = new SftpPatternMatchingFileListFilter(this.filenamePattern); + this.synchronizer.setFilter(filter); this.synchronizer.setAutoCreateDirectories(this.autoCreateDirectories); } } + }