From 0bd4c6c612cbd6608ac2b2222aafb0e6db9b483a Mon Sep 17 00:00:00 2001 From: Iwein Fuld Date: Fri, 22 Oct 2010 09:30:41 +0200 Subject: [PATCH] QUALITY: remove cyclic dependency and start polish in SftpRemoteFileSystemSynchronizingMessageSourceFactoryBean --- .../sftp/config/SftpNamespaceHandler.java | 1 - ...SynchronizingMessageSourceFactoryBean.java | 47 +++++++++++++------ 2 files changed, 33 insertions(+), 15 deletions(-) rename spring-integration-sftp/src/main/java/org/springframework/integration/sftp/{impl => config}/SftpRemoteFileSystemSynchronizingMessageSourceFactoryBean.java (88%) diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/config/SftpNamespaceHandler.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/config/SftpNamespaceHandler.java index 2770d5d3f0..3ca6ac8558 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/config/SftpNamespaceHandler.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/config/SftpNamespaceHandler.java @@ -23,7 +23,6 @@ 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.springframework.integration.sftp.impl.SftpRemoteFileSystemSynchronizingMessageSourceFactoryBean; import org.w3c.dom.Element; diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/impl/SftpRemoteFileSystemSynchronizingMessageSourceFactoryBean.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/config/SftpRemoteFileSystemSynchronizingMessageSourceFactoryBean.java similarity index 88% rename from spring-integration-sftp/src/main/java/org/springframework/integration/sftp/impl/SftpRemoteFileSystemSynchronizingMessageSourceFactoryBean.java rename to spring-integration-sftp/src/main/java/org/springframework/integration/sftp/config/SftpRemoteFileSystemSynchronizingMessageSourceFactoryBean.java index 42db16f148..804082a0ae 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/impl/SftpRemoteFileSystemSynchronizingMessageSourceFactoryBean.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/config/SftpRemoteFileSystemSynchronizingMessageSourceFactoryBean.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.integration.sftp.impl; +package org.springframework.integration.sftp.config; import com.jcraft.jsch.ChannelSftp; import org.apache.commons.lang.SystemUtils; @@ -28,21 +28,20 @@ import org.springframework.integration.file.entries.PatternMatchingEntryListFilt import org.springframework.integration.sftp.QueuedSftpSessionPool; import org.springframework.integration.sftp.SftpEntryNamer; import org.springframework.integration.sftp.SftpSessionFactory; -import org.springframework.integration.sftp.config.SftpSessionUtils; +import org.springframework.integration.sftp.impl.SftpInboundRemoteFileSystemSynchronizer; +import org.springframework.integration.sftp.impl.SftpInboundRemoteFileSystemSynchronizingMessageSource; import org.springframework.util.StringUtils; import java.io.File; /** - * a factory bean to hide the fairly complex configuration possibilities for an SFTP endpoint + * Factory bean to hide the fairly complex configuration possibilities for an SFTP endpoint * * @author Josh Long */ public class SftpRemoteFileSystemSynchronizingMessageSourceFactoryBean extends AbstractFactoryBean implements ResourceLoaderAware { - /** - * injected by the container - */ + private volatile ResourceLoader resourceLoader; private volatile Resource localDirectoryResource; private volatile String localDirectoryPath; @@ -54,9 +53,9 @@ public class SftpRemoteFileSystemSynchronizingMessageSourceFactoryBean extends A private String host; private String keyFile; private String keyFilePassword; - private String password; private String remoteDirectory; private String username; + private String password; @SuppressWarnings("unused") public void setLocalDirectoryResource(Resource localDirectoryResource) { @@ -108,30 +107,50 @@ public class SftpRemoteFileSystemSynchronizingMessageSourceFactoryBean extends A this.keyFilePassword = keyFilePassword; } - @SuppressWarnings("unused") - public void setPassword(String password) { - this.password = password; - } - + /** + * Set the remote directory to synchronize with + */ @SuppressWarnings("unused") public void setRemoteDirectory(String remoteDirectory) { this.remoteDirectory = remoteDirectory; } + /** + * Set the user name to be used for authentication with the remote server + */ @SuppressWarnings("unused") public void setUsername(String username) { this.username = username; } + /** + * Set the password to be used for authentication with the remote server + * @param password + */ + @SuppressWarnings("unused") + public void setPassword(String password) { + this.password = password; + } + + /** + * {@inheritDoc} + */ public void setResourceLoader(ResourceLoader resourceLoader) { this.resourceLoader = resourceLoader; } + /** + * {@inheritDoc} + */ @Override public Class getObjectType() { return SftpRemoteFileSystemSynchronizingMessageSourceFactoryBean.class; } + /** + * {@inheritDoc} + * @return Fully configured SftpInboundRemoteFileSystemSynchronizingMessageSource + */ @Override protected SftpInboundRemoteFileSystemSynchronizingMessageSource createInstance() throws Exception { @@ -148,7 +167,7 @@ public class SftpRemoteFileSystemSynchronizingMessageSourceFactoryBean extends A this.localDirectoryPath = "file://" + sftpTmp.getAbsolutePath(); } - this.localDirectoryResource = this.fromText(localDirectoryPath); + this.localDirectoryResource = this.resourceFromString(localDirectoryPath); // remote predicates SftpEntryNamer sftpEntryNamer = new SftpEntryNamer(); @@ -194,7 +213,7 @@ public class SftpRemoteFileSystemSynchronizingMessageSourceFactoryBean extends A return sftpMsgSrc; } - private Resource fromText(String path) { + private Resource resourceFromString(String path) { ResourceEditor resourceEditor = new ResourceEditor(this.resourceLoader); resourceEditor.setAsText(path);