Skip to content

Commit 3fa777d

Browse files
artembilangaryrussell
authored andcommitted
Expose scan-each-poll for File Inbound Ch Adapter
The `scan-each-poll` XML attribute is missing for the `<int-file:inbound-channel-adapter>`
1 parent 2fbb6fb commit 3fa777d

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

spring-integration-file/src/main/java/org/springframework/integration/file/config/FileInboundChannelAdapterParser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -52,6 +52,7 @@ protected BeanMetadataElement parseSource(Element element, ParserContext parserC
5252
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "directory");
5353
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "auto-create-directory");
5454
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "queue-size");
55+
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "scan-each-poll");
5556
String filterBeanName = this.registerFilter(element, parserContext);
5657
String lockerBeanName = registerLocker(element, parserContext);
5758
if (filterBeanName != null) {

spring-integration-file/src/main/java/org/springframework/integration/file/config/FileReadingMessageSourceFactoryBean.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ public class FileReadingMessageSourceFactoryBean implements FactoryBean<FileRead
7070

7171
private final Object initializationMonitor = new Object();
7272

73-
7473
public void setDirectory(File directory) {
7574
this.directory = directory;
7675
}

spring-integration-file/src/main/resources/org/springframework/integration/file/config/spring-integration-file-5.0.xsd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,17 @@ Only files matching this regular expression will be picked up by this adapter.
182182
</xsd:documentation>
183183
</xsd:annotation>
184184
</xsd:attribute>
185+
<xsd:attribute name="scan-each-poll" default="false">
186+
<xsd:annotation>
187+
<xsd:documentation>
188+
Set this flag if you want to make sure the internal queue is
189+
refreshed with the latest content of the input directory on each poll.
190+
</xsd:documentation>
191+
</xsd:annotation>
192+
<xsd:simpleType>
193+
<xsd:union memberTypes="xsd:boolean xsd:string"/>
194+
</xsd:simpleType>
195+
</xsd:attribute>
185196
</xsd:complexType>
186197
</xsd:element>
187198

spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests-context.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
ignore-hidden="false"
2323
auto-startup="false"
2424
use-watch-service="true"
25+
scan-each-poll="true"
2526
watch-events="MODIFY, DELETE"> <!-- CREATE by default -->
2627
<integration:poller fixed-rate="5000">
2728
<integration:transactional synchronization-factory="syncFactory"/>

spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
1818

1919
import static org.hamcrest.Matchers.containsString;
2020
import static org.hamcrest.Matchers.instanceOf;
21+
import static org.hamcrest.Matchers.is;
2122
import static org.hamcrest.Matchers.isOneOf;
2223
import static org.junit.Assert.assertEquals;
2324
import static org.junit.Assert.assertNotEquals;
@@ -80,7 +81,7 @@ public class FileInboundChannelAdapterParserTests {
8081

8182
@Before
8283
public void init() {
83-
accessor = new DirectFieldAccessor(inputDirPollerSource);
84+
this.accessor = new DirectFieldAccessor(inputDirPollerSource);
8485
}
8586

8687
@Test
@@ -100,8 +101,9 @@ public void justFilter() throws Exception {
100101
@Test
101102
public void inputDirectory() {
102103
File expected = new File(System.getProperty("java.io.tmpdir"));
103-
File actual = (File) accessor.getPropertyValue("directory");
104+
File actual = (File) this.accessor.getPropertyValue("directory");
104105
assertEquals("'directory' should be set", expected, actual);
106+
assertThat(this.accessor.getPropertyValue("scanEachPoll"), is(Boolean.TRUE));
105107
}
106108

107109
@Test

0 commit comments

Comments
 (0)