From 3fa777db5e5510dd269a25eaeb6507c71721fed6 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Fri, 26 Jan 2018 11:21:51 -0500 Subject: [PATCH] Expose scan-each-poll for File Inbound Ch Adapter The `scan-each-poll` XML attribute is missing for the `` --- .../file/config/FileInboundChannelAdapterParser.java | 3 ++- .../config/FileReadingMessageSourceFactoryBean.java | 1 - .../file/config/spring-integration-file-5.0.xsd | 11 +++++++++++ .../FileInboundChannelAdapterParserTests-context.xml | 1 + .../config/FileInboundChannelAdapterParserTests.java | 8 +++++--- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileInboundChannelAdapterParser.java b/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileInboundChannelAdapterParser.java index e3aebf8670..0e29e6a247 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileInboundChannelAdapterParser.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileInboundChannelAdapterParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -52,6 +52,7 @@ public class FileInboundChannelAdapterParser extends AbstractPollingInboundChann IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "directory"); IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "auto-create-directory"); IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "queue-size"); + IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "scan-each-poll"); String filterBeanName = this.registerFilter(element, parserContext); String lockerBeanName = registerLocker(element, parserContext); if (filterBeanName != null) { diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileReadingMessageSourceFactoryBean.java b/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileReadingMessageSourceFactoryBean.java index 20c48387d1..885f32ffb2 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileReadingMessageSourceFactoryBean.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileReadingMessageSourceFactoryBean.java @@ -70,7 +70,6 @@ public class FileReadingMessageSourceFactoryBean implements FactoryBean + + + + Set this flag if you want to make sure the internal queue is + refreshed with the latest content of the input directory on each poll. + + + + + + diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests-context.xml b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests-context.xml index 28f2915745..694007c2af 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests-context.xml +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests-context.xml @@ -22,6 +22,7 @@ ignore-hidden="false" auto-startup="false" use-watch-service="true" + scan-each-poll="true" watch-events="MODIFY, DELETE"> diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests.java index b89e3ce8af..f9f5d976ef 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -18,6 +18,7 @@ package org.springframework.integration.file.config; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.isOneOf; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; @@ -80,7 +81,7 @@ public class FileInboundChannelAdapterParserTests { @Before public void init() { - accessor = new DirectFieldAccessor(inputDirPollerSource); + this.accessor = new DirectFieldAccessor(inputDirPollerSource); } @Test @@ -100,8 +101,9 @@ public class FileInboundChannelAdapterParserTests { @Test public void inputDirectory() { File expected = new File(System.getProperty("java.io.tmpdir")); - File actual = (File) accessor.getPropertyValue("directory"); + File actual = (File) this.accessor.getPropertyValue("directory"); assertEquals("'directory' should be set", expected, actual); + assertThat(this.accessor.getPropertyValue("scanEachPoll"), is(Boolean.TRUE)); } @Test