INT-1614 polished test directory structure, exposed auto-startup attribute on Inbound adapter
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
@@ -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;
|
||||
|
||||
@@ -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"/>
|
||||
@@ -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"/>
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user