INT-1614 polished test directory structure, exposed auto-startup attribute on Inbound adapter

This commit is contained in:
Oleg Zhurakousky
2010-11-16 13:28:00 -05:00
parent f03cf5df1b
commit fda3c380b1
10 changed files with 27 additions and 14 deletions

View File

@@ -61,14 +61,20 @@ class SftpInboundRemoteFileSystemSynchronizingMessageSourceFactoryBean
private volatile FileListFilter<ChannelSftp.LsEntry> filter;
private volatile SftpSessionFactory sftpSessionFactory;
private volatile boolean autoStartup;
private String remoteDirectory;
public void setAutoStartup(boolean autoStartup) {
this.autoStartup = autoStartup;
}
public void setSftpSessionFactory(SftpSessionFactory sftpSessionFactory) {
this.sftpSessionFactory = sftpSessionFactory;
}
private String remoteDirectory;
public void setLocalDirectoryResource(Resource localDirectoryResource) {
this.localDirectoryResource = localDirectoryResource;
}
@@ -158,17 +164,22 @@ class SftpInboundRemoteFileSystemSynchronizingMessageSourceFactoryBean
sftpSync.setBeanFactory(this.getBeanFactory());
sftpSync.setRemotePath(this.remoteDirectory);
sftpSync.afterPropertiesSet();
sftpSync.start();
sftpSync.setAutoStartup(this.autoStartup);
if (this.autoStartup){
sftpSync.start();
}
sftpMsgSrc.setRemotePredicate(compositeFtpFileListFilter);
sftpMsgSrc.setSynchronizer(sftpSync);
sftpMsgSrc.setClientPool(pool);
sftpMsgSrc.setRemotePath(this.remoteDirectory);
sftpMsgSrc.setLocalDirectory(this.localDirectoryResource);
sftpMsgSrc.setBeanFactory(this.getBeanFactory());
sftpMsgSrc.setAutoStartup(true);
sftpMsgSrc.afterPropertiesSet();
sftpMsgSrc.start();
sftpMsgSrc.setAutoStartup(this.autoStartup);
if (this.autoStartup){
sftpMsgSrc.start();
}
return sftpMsgSrc;
}

View File

@@ -53,7 +53,7 @@ public class SftpNamespaceHandler extends AbstractIntegrationNamespaceHandler {
protected BeanMetadataElement parseSource(Element element, ParserContext parserContext) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(SftpInboundRemoteFileSystemSynchronizingMessageSourceFactoryBean.class.getName());
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "filter");
for (String p : "filename-pattern,auto-create-directories,remote-directory,local-directory-path,auto-delete-remote-files-on-sync".split(",")) {
for (String p : "auto-startup,filename-pattern,auto-create-directories,remote-directory,local-directory-path,auto-delete-remote-files-on-sync".split(",")) {
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, p);
}
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "session-factory", "sftpSessionFactory");

View File

@@ -77,6 +77,7 @@ public class SftpInboundRemoteFileSystemSynchronizingMessageSource extends Abstr
try {
session = this.clientPool.getSession();
Assert.state(session != null, "session as returned from the pool should not be null. " + "If it is, it is most likely an error in the pool implementation. ");
session.start();
channelSftp = session.getChannel();

View File

@@ -58,6 +58,7 @@
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string"/>
<xsd:attribute name="session-factory" type="xsd:string" use="required"/>
<xsd:attribute name="auto-startup" type="xsd:string" default="true"/>
<xsd:attribute name="channel" use="required" type="xsd:string">
<xsd:annotation>
<xsd:appinfo>

View File

@@ -20,11 +20,10 @@
<channel id="inboundFilesChannel"/>
<beans:bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.SftpSessionFactory">
<beans:property name="host" value="loclahost"/>
<beans:property name="knownHosts" value="local, foo.com, bar.foo"/>
<beans:property name="privateKey" value="classpath:org/springframework/integration/sftp/sftpTest"/>
<beans:property name="privateKey" value="classpath:org/springframework/integration/sftp/config/sftpTest"/>
<beans:property name="privateKeyPassphrase" value="ghj"/>
<beans:property name="password" value="hello"/>
<beans:property name="port" value="2222"/>
@@ -33,12 +32,13 @@
<sftp:inbound-channel-adapter id="sftpAdapter"
session-factory="sftpSessionFactory"
auto-startup="false"
remote-directory="sftp://hello"
channel="inboundFilesChannel"
filename-pattern=".*?jpg"
auto-create-directories="true"
auto-delete-remote-files-on-sync="true">
<poller fixed-rate="1000"/>
<poller fixed-rate="1000" />
</sftp:inbound-channel-adapter>
</beans:beans>

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.sftp;
package org.springframework.integration.sftp.config;
import static junit.framework.Assert.assertEquals;

View File

@@ -23,7 +23,7 @@
<beans:bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.SftpSessionFactory">
<beans:property name="host" value="loclahost"/>
<beans:property name="knownHosts" value="local, foo.com, bar.foo"/>
<beans:property name="privateKey" value="classpath:org/springframework/integration/sftp/sftpTest"/>
<beans:property name="privateKey" value="classpath:org/springframework/integration/sftp/config/sftpTest"/>
<beans:property name="privateKeyPassphrase" value="ghj"/>
<beans:property name="password" value="hello"/>
<beans:property name="port" value="2222"/>

View File

@@ -23,7 +23,7 @@
<beans:bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.SftpSessionFactory">
<beans:property name="host" value="loclahost"/>
<beans:property name="knownHosts" value="local, foo.com, bar.foo"/>
<beans:property name="privateKey" value="classpath:org/springframework/integration/sftp/sftpTest"/>
<beans:property name="privateKey" value="classpath:org/springframework/integration/sftp/config/sftpTest"/>
<beans:property name="privateKeyPassphrase" value="ghj"/>
<beans:property name="password" value="hello"/>
<beans:property name="port" value="2222"/>

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.sftp;
package org.springframework.integration.sftp.config;
import static junit.framework.Assert.assertTrue;