Skip to content

Commit c5602c4

Browse files
committed
INTEXT-87: Add local-filter attribute
JIRA: https://jira.spring.io/browse/INTEXT-87
1 parent d938146 commit c5602c4

File tree

3 files changed

+59
-30
lines changed

3 files changed

+59
-30
lines changed

spring-integration-smb/src/main/resources/org/springframework/integration/smb/config/spring-integration-smb-1.0.xsd

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,26 @@
193193
</xsd:documentation>
194194
</xsd:annotation>
195195
</xsd:attribute>
196+
<xsd:attribute name="local-filter" type="xsd:string">
197+
<xsd:annotation>
198+
<xsd:appinfo>
199+
<tool:annotation kind="ref">
200+
<tool:expected-type
201+
type="org.springframework.integration.file.filters.FileListFilter" />
202+
</tool:annotation>
203+
</xsd:appinfo>
204+
<xsd:documentation>
205+
Allows you to specify a reference to a
206+
[org.springframework.integration.file.filters.FileListFilter]
207+
bean. This filter is applied to files after they have been
208+
retrieved. The default is an AcceptOnceFileListFilter which means that,
209+
even if a new instance of a file is retrieved from the remote server,
210+
a message won't be generated. The filter provided here is combined
211+
with a filter that prevents the message source from processing
212+
files that are currently being downloaded.
213+
</xsd:documentation>
214+
</xsd:annotation>
215+
</xsd:attribute>
196216
<xsd:attribute name="local-directory" type="xsd:string" use="required">
197217
<xsd:annotation>
198218
<xsd:documentation>

spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbInboundChannelAdapterParserTests-context.xml

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,58 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<beans xmlns="http://www.springframework.org/schema/beans"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xmlns:p="http://www.springframework.org/schema/p"
5-
xmlns:int="http://www.springframework.org/schema/integration"
6-
xmlns:int-smb="http://www.springframework.org/schema/integration/smb"
7-
xsi:schemaLocation="http://www.springframework.org/schema/beans
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:int="http://www.springframework.org/schema/integration"
5+
xmlns:int-smb="http://www.springframework.org/schema/integration/smb"
6+
xsi:schemaLocation="http://www.springframework.org/schema/beans
87
http://www.springframework.org/schema/beans/spring-beans.xsd
98
http://www.springframework.org/schema/integration
109
http://www.springframework.org/schema/integration/spring-integration.xsd
1110
http://www.springframework.org/schema/integration/smb
1211
http://www.springframework.org/schema/integration/smb/spring-integration-smb.xsd">
1312

1413
<bean id="smbSessionFactory"
15-
class="org.springframework.integration.smb.config.SmbInboundChannelAdapterParserTests.TestSessionFactoryBean"/>
14+
class="org.springframework.integration.smb.config.SmbInboundChannelAdapterParserTests.TestSessionFactoryBean"/>
15+
16+
<bean id="acceptAllFilter" class="org.springframework.integration.file.filters.AcceptAllFileListFilter"/>
1617

1718
<int-smb:inbound-channel-adapter id="smbInbound"
18-
channel="smbChannel"
19-
session-factory="smbSessionFactory"
20-
charset="UTF-8"
21-
auto-create-local-directory="true"
22-
delete-remote-files="true"
23-
filename-pattern="*.txt"
24-
local-directory="file:test-temp/local-1"
25-
remote-file-separator=""
26-
comparator="comparator"
27-
temporary-file-suffix=".working.tmp"
28-
remote-directory="test-temp/remote-1">
19+
auto-startup="false"
20+
channel="smbChannel"
21+
session-factory="smbSessionFactory"
22+
charset="UTF-8"
23+
auto-create-local-directory="true"
24+
delete-remote-files="true"
25+
filename-pattern="*.txt"
26+
local-filter="acceptAllFilter"
27+
local-directory="file:test-temp/local-1"
28+
remote-file-separator=""
29+
comparator="comparator"
30+
temporary-file-suffix=".working.tmp"
31+
remote-directory="test-temp/remote-1">
2932
</int-smb:inbound-channel-adapter>
3033

3134
<bean id="comparator" class="org.mockito.Mockito" factory-method="mock">
3235
<constructor-arg value="java.util.Comparator"/>
3336
</bean>
3437

3538
<int-smb:inbound-channel-adapter
36-
channel="smbChannel"
37-
session-factory="smbSessionFactory"
38-
charset="UTF-8"
39-
auto-create-local-directory="true"
40-
delete-remote-files="true"
41-
filter="entryListFilter"
42-
local-directory="file:test-temp/local-2"
43-
remote-directory="test-temp/remote-2">
39+
channel="smbChannel"
40+
auto-startup="false"
41+
session-factory="smbSessionFactory"
42+
charset="UTF-8"
43+
auto-create-local-directory="true"
44+
delete-remote-files="true"
45+
filter="entryListFilter"
46+
local-directory="file:test-temp/local-2"
47+
remote-directory="test-temp/remote-2">
4448
</int-smb:inbound-channel-adapter>
4549

4650
<int-smb:inbound-channel-adapter id="simpleAdapter"
47-
channel="smbChannel"
48-
session-factory="smbSessionFactory"
49-
local-directory="file:test-temp/local-3"
50-
remote-directory="test-temp/remote-3">
51+
channel="smbChannel"
52+
auto-startup="false"
53+
session-factory="smbSessionFactory"
54+
local-directory="file:test-temp/local-3"
55+
remote-directory="test-temp/remote-3">
5156
</int-smb:inbound-channel-adapter>
5257

5358
<int:channel id="smbChannel">

spring-integration-smb/src/test/java/org/springframework/integration/smb/config/SmbInboundChannelAdapterParserTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import static org.mockito.Mockito.mock;
2525
import static org.mockito.Mockito.when;
2626

27+
import java.util.Collection;
2728
import java.util.Iterator;
2829
import java.util.Map;
2930
import java.util.Set;
@@ -69,7 +70,6 @@ public void testSmbInboundChannelAdapterComplete() {
6970
assertNotNull(queue.comparator());
7071
assertEquals("smbInbound", adapter.getComponentName());
7172
assertEquals("smb:inbound-channel-adapter", adapter.getComponentType());
72-
assertNotNull(TestUtils.getPropertyValue(adapter, "poller"));
7373
assertEquals(applicationContext.getBean("smbChannel"), TestUtils.getPropertyValue(adapter, "outputChannel"));
7474
SmbInboundFileSynchronizingMessageSource inbound =
7575
(SmbInboundFileSynchronizingMessageSource) TestUtils.getPropertyValue(adapter, "source");
@@ -90,6 +90,10 @@ public void testSmbInboundChannelAdapterComplete() {
9090
assertThat(filtersIterator.next(), instanceOf(SmbPersistentAcceptOnceFileListFilter.class));
9191
Object sessionFactory = TestUtils.getPropertyValue(fisync, "remoteFileTemplate.sessionFactory");
9292
assertTrue(SmbSessionFactory.class.isAssignableFrom(sessionFactory.getClass()));
93+
94+
FileListFilter<?> acceptAllFilter = this.applicationContext.getBean("acceptAllFilter", FileListFilter.class);
95+
assertTrue(TestUtils.getPropertyValue(inbound, "fileSource.scanner.filter.fileFilters", Collection.class)
96+
.contains(acceptAllFilter));
9397
}
9498

9599
@Test

0 commit comments

Comments
 (0)