Polished. This fixes #687
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/acc42056 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/acc42056 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/acc42056 Branch: refs/heads/master Commit: acc4205675182869acab1ba047e85d0eeb2c226f Parents: e6f7c01 Author: Claus Ibsen <davscl...@apache.org> Authored: Wed Nov 25 14:17:35 2015 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed Nov 25 14:17:35 2015 +0100 ---------------------------------------------------------------------- .../component/file/GenericFileConsumer.java | 27 +++++++++++++++----- .../component/file/GenericFileEndpoint.java | 4 +-- 2 files changed, 22 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/acc42056/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java index 2084c57..0d31545 100644 --- a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java +++ b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java @@ -22,13 +22,13 @@ import java.util.Deque; import java.util.LinkedList; import java.util.List; import java.util.Queue; +import java.util.regex.Pattern; import org.apache.camel.AsyncCallback; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.ShutdownRunningTask; import org.apache.camel.impl.ScheduledBatchPollingConsumer; -import org.apache.camel.spi.UriParam; import org.apache.camel.util.CastUtils; import org.apache.camel.util.ObjectHelper; import org.apache.camel.util.StopWatch; @@ -40,6 +40,9 @@ import org.slf4j.LoggerFactory; * Base class for file consumers. */ public abstract class GenericFileConsumer<T> extends ScheduledBatchPollingConsumer { + private final Pattern excludePattern; + private final Pattern includePattern; + protected final Logger log = LoggerFactory.getLogger(getClass()); protected GenericFileEndpoint<T> endpoint; protected GenericFileOperations<T> operations; @@ -48,7 +51,6 @@ public abstract class GenericFileConsumer<T> extends ScheduledBatchPollingConsum protected volatile ShutdownRunningTask shutdownRunningTask; protected volatile int pendingExchanges; protected Processor customProcessor; - @UriParam protected boolean eagerLimitMaxMessagesPerPoll = true; protected volatile boolean prepareOnStartup; @@ -56,6 +58,17 @@ public abstract class GenericFileConsumer<T> extends ScheduledBatchPollingConsum super(endpoint, processor); this.endpoint = endpoint; this.operations = operations; + + if (endpoint.getInclude() != null) { + this.includePattern = Pattern.compile(endpoint.getInclude(), Pattern.CASE_INSENSITIVE); + } else { + this.includePattern = null; + } + if (endpoint.getExclude() != null) { + this.excludePattern = Pattern.compile(endpoint.getExclude(), Pattern.CASE_INSENSITIVE); + } else { + this.excludePattern = null; + } } public Processor getCustomProcessor() { @@ -597,14 +610,14 @@ public abstract class GenericFileConsumer<T> extends ScheduledBatchPollingConsum return true; } - if (ObjectHelper.isNotEmpty(endpoint.getExclude())) { - if (name.toUpperCase().matches(endpoint.getExclude().toUpperCase())) { + // exclude take precedence over include + if (excludePattern != null) { + if (excludePattern.matcher(name).matches()) { return false; } } - - if (ObjectHelper.isNotEmpty(endpoint.getInclude())) { - if (!name.toUpperCase().matches(endpoint.getInclude().toUpperCase())) { + if (includePattern != null) { + if (!includePattern.matcher(name).matches()) { return false; } } http://git-wip-us.apache.org/repos/asf/camel/blob/acc42056/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java index c81e2d3..9c4586d 100644 --- a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java +++ b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java @@ -416,7 +416,7 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple } /** - * Is used to include files, if filename matches the regex pattern. + * Is used to include files, if filename matches the regex pattern (matching is case in-senstive). * <p/> * Notice if you use symbols such as plus sign and others you would need to configure * this using the RAW() syntax if configuring this as an endpoint uri. @@ -431,7 +431,7 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple } /** - * Is used to exclude files, if filename matches the regex pattern. + * Is used to exclude files, if filename matches the regex pattern (matching is case in-senstive). * <p/> * Notice if you use symbols such as plus sign and others you would need to configure * this using the RAW() syntax if configuring this as an endpoint uri.