INT-2892 Add 'local-filter' to (S)FTP Adapters
Allow the replacement of the default AcceptOnceFileListFilter.
This commit is contained in:
committed by
Gunnar Hillert
parent
e6753efd50
commit
14a7953ff6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,6 +31,7 @@ import org.w3c.dom.Element;
|
||||
*
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
public abstract class AbstractRemoteFileInboundChannelAdapterParser extends AbstractPollingInboundChannelAdapterParser {
|
||||
@@ -62,6 +63,7 @@ public abstract class AbstractRemoteFileInboundChannelAdapterParser extends Abst
|
||||
if (StringUtils.hasText(comparator)) {
|
||||
messageSourceBuilder.addConstructorArgReference(comparator);
|
||||
}
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(messageSourceBuilder, element, "local-filter");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(messageSourceBuilder, element, "local-directory");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(messageSourceBuilder, element, "auto-create-local-directory");
|
||||
String localFileGeneratorExpression = element.getAttribute("local-filename-generator-expression");
|
||||
|
||||
@@ -79,6 +79,8 @@ public abstract class AbstractInboundFileSynchronizingMessageSource<F> extends M
|
||||
*/
|
||||
private final FileReadingMessageSource fileSource;
|
||||
|
||||
private volatile FileListFilter<File> localFileListFilter = new AcceptOnceFileListFilter<File>();
|
||||
|
||||
|
||||
public AbstractInboundFileSynchronizingMessageSource(AbstractInboundFileSynchronizer<F> synchronizer) {
|
||||
this(synchronizer, null);
|
||||
@@ -104,6 +106,20 @@ public abstract class AbstractInboundFileSynchronizingMessageSource<F> extends M
|
||||
this.localDirectory = localDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link FileListFilter} used to determine which files will generate messages
|
||||
* after they have been synchronized. It will be combined with a filter that
|
||||
* will prevent accessing files that are in the process of being synchronized
|
||||
* (files having the {@link AbstractInboundFileSynchronizer#getTemporaryFileSuffix()}).
|
||||
* <p>
|
||||
* The default is an {@link AcceptOnceFileListFilter} which filters duplicate file
|
||||
* names (processed during the current execution).
|
||||
* @param localFileListFilter
|
||||
*/
|
||||
public void setLocalFilter(FileListFilter<File> localFileListFilter) {
|
||||
this.localFileListFilter = localFileListFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInit() {
|
||||
Assert.notNull(this.localDirectory, "localDirectory must not be null");
|
||||
@@ -153,7 +169,7 @@ public abstract class AbstractInboundFileSynchronizingMessageSource<F> extends M
|
||||
private FileListFilter<File> buildFilter() {
|
||||
Pattern completePattern = Pattern.compile("^.*(?<!" + this.synchronizer.getTemporaryFileSuffix() + ")$");
|
||||
return new CompositeFileListFilter<File>(Arrays.asList(
|
||||
new AcceptOnceFileListFilter<File>(),
|
||||
this.localFileListFilter,
|
||||
new RegexPatternFileListFilter(completePattern)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user