This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch poll-dyn
in repository https://gitbox.apache.org/repos/asf/camel.git

commit bb355e1f516f9c266dbc43df6d3fc6834abc5b56
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat Feb 8 10:40:38 2025 +0100

    CAMEL-21733: camel-core - Poll EIP to support DynamicAware to reuse 
endpoints during dynamic poll EIP
---
 .../apache/camel/catalog/models/pollEnrich.json    |  3 ++-
 .../apache/camel/catalog/schemas/camel-spring.xsd  |  9 ++++++++
 .../camel/component/file/azure/FilesConsumer.java  | 20 ++++++++++------
 .../camel/component/file/remote/FtpConsumer.java   | 27 +++++++++++++---------
 .../component/file/remote/RemoteFileConsumer.java  |  8 ++++---
 .../camel/component/file/remote/SftpConsumer.java  | 14 ++++++-----
 .../remote/RemoteFileIgnoreDoPollErrorTest.java    | 12 ++++++----
 .../apache/camel/component/smb/SmbConsumer.java    | 18 +++++++++------
 .../dsl/yaml/deserializers/ModelDeserializers.java |  6 +++++
 .../generated/resources/schema/camelYamlDsl.json   |  5 ++++
 10 files changed, 82 insertions(+), 40 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/pollEnrich.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/pollEnrich.json
index 85409de3ace..5644c4a8a54 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/pollEnrich.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/pollEnrich.json
@@ -24,7 +24,8 @@
     "timeout": { "index": 9, "kind": "attribute", "displayName": "Timeout", 
"group": "common", "required": false, "type": "duration", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": "-1", "description": "Timeout in millis when polling from the 
external service. The timeout has influence about the poll enrich behavior. It 
basically operations in three different modes: negative value - Waits until a 
message is available and then ret [...]
     "cacheSize": { "index": 10, "kind": "attribute", "displayName": "Cache 
Size", "group": "advanced", "label": "advanced", "required": false, "type": 
"integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": 
false, "secret": false, "description": "Sets the maximum size used by the 
org.apache.camel.spi.ConsumerCache which is used to cache and reuse consumers 
when uris are reused. Beware that when using dynamic endpoints then it affects 
how well the cache can be utiliz [...]
     "ignoreInvalidEndpoint": { "index": 11, "kind": "attribute", 
"displayName": "Ignore Invalid Endpoint", "group": "advanced", "label": 
"advanced", "required": false, "type": "boolean", "javaType": 
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Ignore the invalidate endpoint exception 
when try to create a producer with that endpoint" },
-    "autoStartComponents": { "index": 12, "kind": "attribute", "displayName": 
"Auto Start Components", "group": "advanced", "label": "advanced", "required": 
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": true, "description": 
"Whether to auto startup components when poll enricher is starting up." }
+    "allowOptimisedComponents": { "index": 12, "kind": "attribute", 
"displayName": "Allow Optimised Components", "group": "advanced", "label": 
"advanced", "required": false, "type": "boolean", "javaType": 
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": true, "description": "Whether to allow components to optimise 
if they are org.apache.camel.spi.SendDynamicAware ." },
+    "autoStartComponents": { "index": 13, "kind": "attribute", "displayName": 
"Auto Start Components", "group": "advanced", "label": "advanced", "required": 
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": true, "description": 
"Whether to auto startup components when poll enricher is starting up." }
   },
   "exchangeProperties": {
     "CamelToEndpoint": { "index": 0, "kind": "exchangeProperty", 
"displayName": "To Endpoint", "label": "producer", "required": false, 
"javaType": "String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Endpoint URI where this Exchange is being sent to" }
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
index 06008c197e7..216510d472e 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
@@ -11816,6 +11816,15 @@ storing too many non frequent used producers.
             <xs:documentation xml:lang="en">
 <![CDATA[
 Ignore the invalidate endpoint exception when try to create a producer with 
that endpoint. Default value: false
+]]>
+            </xs:documentation>
+          </xs:annotation>
+        </xs:attribute>
+        <xs:attribute name="allowOptimisedComponents" type="xs:string">
+          <xs:annotation>
+            <xs:documentation xml:lang="en">
+<![CDATA[
+Whether to allow components to optimise if they are 
org.apache.camel.spi.SendDynamicAware . Default value: true
 ]]>
             </xs:documentation>
           </xs:annotation>
diff --git 
a/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesConsumer.java
 
b/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesConsumer.java
index 4a8bd13cbd9..80ac733f457 100644
--- 
a/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesConsumer.java
+++ 
b/components/camel-azure/camel-azure-files/src/main/java/org/apache/camel/component/file/azure/FilesConsumer.java
@@ -22,6 +22,7 @@ import java.util.List;
 import java.util.function.Supplier;
 
 import com.azure.storage.file.share.models.ShareFileItem;
+import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.api.management.ManagedResource;
@@ -89,15 +90,17 @@ public class FilesConsumer extends 
RemoteFileConsumer<ShareFileItem> {
 
     @Override
     protected boolean pollDirectory(
+            Exchange dynamic,
             String path, List<GenericFile<ShareFileItem>> fileList,
             int depth) {
         LOG.trace("pollDirectory({},,{})", path, depth);
 
-        return doPollDirectory(FilesPath.trimTrailingSeparator(path), null, 
fileList, depth);
+        return doPollDirectory(dynamic, FilesPath.trimTrailingSeparator(path), 
null, fileList, depth);
     }
 
     @Override
     protected boolean doPollDirectory(
+            Exchange dynamic,
             String path, String dirName,
             List<GenericFile<ShareFileItem>> fileList, int depth) {
         LOG.trace("doPollDirectory({},{},,{})", path, dirName, depth);
@@ -119,7 +122,7 @@ public class FilesConsumer extends 
RemoteFileConsumer<ShareFileItem> {
         }
 
         for (var fileItem : listedFileItems) {
-            if (handleFileItem(path, fileList, depth + 1, listedFileItems, 
fileItem)) {
+            if (handleFileItem(dynamic, path, fileList, depth + 1, 
listedFileItems, fileItem)) {
                 return false;
             }
         }
@@ -128,6 +131,7 @@ public class FilesConsumer extends 
RemoteFileConsumer<ShareFileItem> {
     }
 
     private boolean handleFileItem(
+            Exchange dynamic,
             String path, List<GenericFile<ShareFileItem>> polledFiles,
             int depth, ShareFileItem[] listedFileItems, ShareFileItem 
fileItem) {
         if (LOG.isTraceEnabled()) {
@@ -140,16 +144,17 @@ public class FilesConsumer extends 
RemoteFileConsumer<ShareFileItem> {
         }
 
         if (fileItem.isDirectory()) {
-            if (handleDirectory(path, polledFiles, depth, listedFileItems, 
fileItem)) {
+            if (handleDirectory(dynamic, path, polledFiles, depth, 
listedFileItems, fileItem)) {
                 return true;
             }
         } else {
-            handleFile(path, polledFiles, depth, listedFileItems, fileItem);
+            handleFile(dynamic, path, polledFiles, depth, listedFileItems, 
fileItem);
         }
         return false;
     }
 
     private boolean handleDirectory(
+            Exchange dynamic,
             String path, List<GenericFile<ShareFileItem>> polledFiles,
             int depth, ShareFileItem[] listedFileItems, ShareFileItem dir) {
 
@@ -157,10 +162,10 @@ public class FilesConsumer extends 
RemoteFileConsumer<ShareFileItem> {
             Supplier<GenericFile<ShareFileItem>> remote = 
Suppliers.memorize(() -> asRemoteFile(path, dir));
             String absoluteFilePath = FilesPath.concat(path, dir.getName());
             Supplier<String> relative = getRelativeFilePath(endpointPath, 
path, absoluteFilePath, dir);
-            if (isValidFile(remote, dir.getName(), absoluteFilePath, relative, 
true, listedFileItems)) {
+            if (isValidFile(dynamic, remote, dir.getName(), absoluteFilePath, 
relative, true, listedFileItems)) {
                 String dirName = dir.getName();
                 String dirPath = FilesPath.concat(path, dirName);
-                boolean canPollMore = doSafePollSubDirectory(dirPath, dirName, 
polledFiles, depth);
+                boolean canPollMore = doSafePollSubDirectory(dynamic, dirPath, 
dirName, polledFiles, depth);
                 if (!canPollMore) {
                     return true;
                 }
@@ -170,13 +175,14 @@ public class FilesConsumer extends 
RemoteFileConsumer<ShareFileItem> {
     }
 
     private void handleFile(
+            Exchange dynamic,
             String path, List<GenericFile<ShareFileItem>> polledFiles, int 
depth,
             ShareFileItem[] listedFileItems, ShareFileItem file) {
         if (depth >= endpoint.getMinDepth()) {
             Supplier<GenericFile<ShareFileItem>> remote = 
Suppliers.memorize(() -> asRemoteFile(path, file));
             String absoluteFilePath = FilesPath.concat(path, file.getName());
             Supplier<String> relative = getRelativeFilePath(endpointPath, 
path, absoluteFilePath, file);
-            if (isValidFile(remote, file.getName(), absoluteFilePath, 
relative, false,
+            if (isValidFile(dynamic, remote, file.getName(), absoluteFilePath, 
relative, false,
                     listedFileItems)) {
                 polledFiles.add(remote.get());
             }
diff --git 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java
 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java
index d7f931c019d..2b7c5dced54 100644
--- 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java
+++ 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java
@@ -94,7 +94,7 @@ public class FtpConsumer extends RemoteFileConsumer<FTPFile> {
     }
 
     @Override
-    protected boolean pollDirectory(String fileName, 
List<GenericFile<FTPFile>> fileList, int depth) {
+    protected boolean pollDirectory(Exchange dynamic, String fileName, 
List<GenericFile<FTPFile>> fileList, int depth) {
         String currentDir = null;
         if (isStepwise()) {
             // must remember current dir so we stay in that directory after the
@@ -105,7 +105,7 @@ public class FtpConsumer extends 
RemoteFileConsumer<FTPFile> {
         // strip trailing slash
         fileName = FileUtil.stripTrailingSeparator(fileName);
 
-        boolean answer = doPollDirectory(fileName, null, fileList, depth);
+        boolean answer = doPollDirectory(dynamic, fileName, null, fileList, 
depth);
         if (currentDir != null) {
             operations.changeCurrentDirectory(currentDir);
         }
@@ -113,8 +113,9 @@ public class FtpConsumer extends 
RemoteFileConsumer<FTPFile> {
         return answer;
     }
 
-    protected boolean pollSubDirectory(String absolutePath, String dirName, 
List<GenericFile<FTPFile>> fileList, int depth) {
-        boolean answer = doSafePollSubDirectory(absolutePath, dirName, 
fileList, depth);
+    protected boolean pollSubDirectory(
+            Exchange dynamic, String absolutePath, String dirName, 
List<GenericFile<FTPFile>> fileList, int depth) {
+        boolean answer = doSafePollSubDirectory(dynamic, absolutePath, 
dirName, fileList, depth);
         // change back to parent directory when finished polling sub directory
         if (isStepwise()) {
             operations.changeToParentDirectory();
@@ -123,7 +124,8 @@ public class FtpConsumer extends 
RemoteFileConsumer<FTPFile> {
     }
 
     @Override
-    protected boolean doPollDirectory(String absolutePath, String dirName, 
List<GenericFile<FTPFile>> fileList, int depth) {
+    protected boolean doPollDirectory(
+            Exchange dynamic, String absolutePath, String dirName, 
List<GenericFile<FTPFile>> fileList, int depth) {
         LOG.trace("doPollDirectory from absolutePath: {}, dirName: {}", 
absolutePath, dirName);
 
         depth++;
@@ -150,7 +152,7 @@ public class FtpConsumer extends 
RemoteFileConsumer<FTPFile> {
         }
 
         for (FTPFile file : files) {
-            if (handleFtpEntries(absolutePath, fileList, depth, files, file)) {
+            if (handleFtpEntries(dynamic, absolutePath, fileList, depth, 
files, file)) {
                 return false;
             }
         }
@@ -159,6 +161,7 @@ public class FtpConsumer extends 
RemoteFileConsumer<FTPFile> {
     }
 
     private boolean handleFtpEntries(
+            Exchange dynamic,
             String absolutePath, List<GenericFile<FTPFile>> fileList, int 
depth, FTPFile[] files, FTPFile file) {
         if (LOG.isTraceEnabled()) {
             LOG.trace("FtpFile[name={}, dir={}, file={}]", file.getName(), 
file.isDirectory(), file.isFile());
@@ -170,11 +173,11 @@ public class FtpConsumer extends 
RemoteFileConsumer<FTPFile> {
         }
 
         if (file.isDirectory()) {
-            if (handleDirectory(absolutePath, fileList, depth, files, file)) {
+            if (handleDirectory(dynamic, absolutePath, fileList, depth, files, 
file)) {
                 return true;
             }
         } else if (file.isFile()) {
-            handleFile(absolutePath, fileList, depth, files, file);
+            handleFile(dynamic, absolutePath, fileList, depth, files, file);
         } else {
             LOG.debug("Ignoring unsupported remote file type: {}", file);
         }
@@ -182,6 +185,7 @@ public class FtpConsumer extends 
RemoteFileConsumer<FTPFile> {
     }
 
     private boolean handleDirectory(
+            Exchange dynamic,
             String absolutePath, List<GenericFile<FTPFile>> fileList, int 
depth, FTPFile[] files, FTPFile file) {
         if (endpoint.isRecursive() && depth < endpoint.getMaxDepth()) {
             // calculate the absolute file path using util class
@@ -190,11 +194,11 @@ public class FtpConsumer extends 
RemoteFileConsumer<FTPFile> {
             Supplier<GenericFile<FTPFile>> remote
                     = Suppliers.memorize(() -> asRemoteFile(absolutePath, 
absoluteFilePath, file, getEndpoint().getCharset()));
             Supplier<String> relativePath = getRelativeFilePath(endpointPath, 
null, absolutePath, file);
-            if (isValidFile(remote, file.getName(), absoluteFilePath, 
relativePath, true, files)) {
+            if (isValidFile(dynamic, remote, file.getName(), absoluteFilePath, 
relativePath, true, files)) {
                 // recursive scan and add the sub files and folders
                 String subDirectory = file.getName();
                 String path = ObjectHelper.isNotEmpty(absolutePath) ? 
absolutePath + "/" + subDirectory : subDirectory;
-                boolean canPollMore = pollSubDirectory(path, subDirectory, 
fileList, depth);
+                boolean canPollMore = pollSubDirectory(dynamic, path, 
subDirectory, fileList, depth);
                 if (!canPollMore) {
                     return true;
                 }
@@ -204,6 +208,7 @@ public class FtpConsumer extends 
RemoteFileConsumer<FTPFile> {
     }
 
     private void handleFile(
+            Exchange dynamic,
             String absolutePath, List<GenericFile<FTPFile>> fileList, int 
depth, FTPFile[] files, FTPFile file) {
         if (depth >= endpoint.getMinDepth()) {
             // calculate the absolute file path using util class
@@ -212,7 +217,7 @@ public class FtpConsumer extends 
RemoteFileConsumer<FTPFile> {
             Supplier<GenericFile<FTPFile>> remote
                     = Suppliers.memorize(() -> asRemoteFile(absolutePath, 
absoluteFilePath, file, getEndpoint().getCharset()));
             Supplier<String> relativePath = getRelativeFilePath(endpointPath, 
null, absolutePath, file);
-            if (isValidFile(remote, file.getName(), absoluteFilePath, 
relativePath, false, files)) {
+            if (isValidFile(dynamic, remote, file.getName(), absoluteFilePath, 
relativePath, false, files)) {
                 // matched file so add
                 fileList.add(remote.get());
             }
diff --git 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
index 0b268ae4ee3..0031178e20f 100644
--- 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
+++ 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
@@ -251,11 +251,12 @@ public abstract class RemoteFileConsumer<T> extends 
GenericFileConsumer<T> {
      *                                             maxMessagesPerPoll limit 
has been hit
      * @throws GenericFileOperationFailedException if the exception during 
doPollDirectory can not be ignored
      */
-    protected boolean doSafePollSubDirectory(String absolutePath, String 
dirName, List<GenericFile<T>> fileList, int depth) {
+    protected boolean doSafePollSubDirectory(
+            Exchange dynamic, String absolutePath, String dirName, 
List<GenericFile<T>> fileList, int depth) {
         try {
             LOG.trace("Polling sub directory: {} from: {}", absolutePath, 
endpoint);
             // Try to poll the directory
-            return doPollDirectory(absolutePath, dirName, fileList, depth);
+            return doPollDirectory(dynamic, absolutePath, dirName, fileList, 
depth);
         } catch (Exception e) {
             LOG.debug("Caught exception {}", e.getMessage());
             if (ignoreCannotRetrieveFile(absolutePath, null, e)) {
@@ -285,5 +286,6 @@ public abstract class RemoteFileConsumer<T> extends 
GenericFileConsumer<T> {
      * @return              whether or not to continue polling, <tt>false</tt> 
means the maxMessagesPerPoll limit has
      *                      been hit
      */
-    protected abstract boolean doPollDirectory(String absolutePath, String 
dirName, List<GenericFile<T>> fileList, int depth);
+    protected abstract boolean doPollDirectory(
+            Exchange dynamic, String absolutePath, String dirName, 
List<GenericFile<T>> fileList, int depth);
 }
diff --git 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java
 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java
index d231d6a3fd8..d27e336ba6c 100644
--- 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java
+++ 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java
@@ -86,7 +86,7 @@ public class SftpConsumer extends 
RemoteFileConsumer<SftpRemoteFile> {
     }
 
     @Override
-    protected boolean pollDirectory(String fileName, 
List<GenericFile<SftpRemoteFile>> fileList, int depth) {
+    protected boolean pollDirectory(Exchange dynamic, String fileName, 
List<GenericFile<SftpRemoteFile>> fileList, int depth) {
         String currentDir = null;
         if (isStepwise()) {
             // must remember current dir so we stay in that directory after the
@@ -97,7 +97,7 @@ public class SftpConsumer extends 
RemoteFileConsumer<SftpRemoteFile> {
         // strip trailing slash
         fileName = FileUtil.stripTrailingSeparator(fileName);
 
-        boolean answer = doPollDirectory(fileName, null, fileList, depth);
+        boolean answer = doPollDirectory(dynamic, fileName, null, fileList, 
depth);
         if (currentDir != null) {
             operations.changeCurrentDirectory(currentDir);
         }
@@ -106,8 +106,9 @@ public class SftpConsumer extends 
RemoteFileConsumer<SftpRemoteFile> {
     }
 
     protected boolean pollSubDirectory(
+            Exchange dynamic,
             String absolutePath, String dirName, 
List<GenericFile<SftpRemoteFile>> fileList, int depth) {
-        boolean answer = doSafePollSubDirectory(absolutePath, dirName, 
fileList, depth);
+        boolean answer = doSafePollSubDirectory(dynamic, absolutePath, 
dirName, fileList, depth);
         // change back to parent directory when finished polling sub directory
         if (isStepwise()) {
             operations.changeToParentDirectory();
@@ -117,6 +118,7 @@ public class SftpConsumer extends 
RemoteFileConsumer<SftpRemoteFile> {
 
     @Override
     protected boolean doPollDirectory(
+            Exchange dynamic,
             String absolutePath, String dirName, 
List<GenericFile<SftpRemoteFile>> fileList, int depth) {
         LOG.trace("doPollDirectory from absolutePath: {}, dirName: {}", 
absolutePath, dirName);
 
@@ -168,11 +170,11 @@ public class SftpConsumer extends 
RemoteFileConsumer<SftpRemoteFile> {
                             = Suppliers.memorize(
                                     () -> asRemoteFile(absolutePath, 
absoluteFilePath, file, getEndpoint().getCharset()));
                     Supplier<String> relativePath = 
getRelativeFilePath(endpointPath, null, absolutePath, file);
-                    if (isValidFile(remote, file.getFilename(), 
absoluteFilePath, relativePath, true, files)) {
+                    if (isValidFile(dynamic, remote, file.getFilename(), 
absoluteFilePath, relativePath, true, files)) {
                         // recursive scan and add the sub files and folders
                         String subDirectory = file.getFilename();
                         String path = ObjectHelper.isNotEmpty(absolutePath) ? 
absolutePath + "/" + subDirectory : subDirectory;
-                        boolean canPollMore = pollSubDirectory(path, 
subDirectory, fileList, depth);
+                        boolean canPollMore = pollSubDirectory(dynamic, path, 
subDirectory, fileList, depth);
                         if (!canPollMore) {
                             return false;
                         }
@@ -188,7 +190,7 @@ public class SftpConsumer extends 
RemoteFileConsumer<SftpRemoteFile> {
                             = Suppliers.memorize(
                                     () -> asRemoteFile(absolutePath, 
absoluteFilePath, file, getEndpoint().getCharset()));
                     Supplier<String> relativePath = 
getRelativeFilePath(endpointPath, null, absolutePath, file);
-                    if (isValidFile(remote, file.getFilename(), 
absoluteFilePath, relativePath, false, files)) {
+                    if (isValidFile(dynamic, remote, file.getFilename(), 
absoluteFilePath, relativePath, false, files)) {
                         // matched file so add
                         fileList.add(remote.get());
                     }
diff --git 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/RemoteFileIgnoreDoPollErrorTest.java
 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/RemoteFileIgnoreDoPollErrorTest.java
index 780d3d5f1a6..bd6e173712f 100644
--- 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/RemoteFileIgnoreDoPollErrorTest.java
+++ 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/RemoteFileIgnoreDoPollErrorTest.java
@@ -72,14 +72,14 @@ public class RemoteFileIgnoreDoPollErrorTest {
     @Test
     public void testReadDirErrorIsHandled() {
         RemoteFileConsumer<Object> consumer = getRemoteFileConsumer("true", 
true);
-        boolean result = consumer.doSafePollSubDirectory("anyPath", "adir", 
new ArrayList<>(), 0);
+        boolean result = consumer.doSafePollSubDirectory(null, "anyPath", 
"adir", new ArrayList<>(), 0);
         assertTrue(result);
     }
 
     @Test
     public void testReadDirErrorIsHandledWithNoMorePoll() {
         RemoteFileConsumer<Object> consumer = getRemoteFileConsumer("false", 
true);
-        boolean result = consumer.doSafePollSubDirectory("anyPath", "adir", 
new ArrayList<>(), 0);
+        boolean result = consumer.doSafePollSubDirectory(null, "anyPath", 
"adir", new ArrayList<>(), 0);
         assertFalse(result);
     }
 
@@ -89,7 +89,7 @@ public class RemoteFileIgnoreDoPollErrorTest {
         List<GenericFile<Object>> list = Collections.emptyList();
 
         Exception ex = assertThrows(GenericFileOperationFailedException.class,
-                () -> consumer.doSafePollSubDirectory("anyPath", "adir", list, 
0));
+                () -> consumer.doSafePollSubDirectory(null, "anyPath", "adir", 
list, 0));
 
         assertInstanceOf(IllegalStateException.class, ex.getCause());
     }
@@ -100,7 +100,7 @@ public class RemoteFileIgnoreDoPollErrorTest {
         List<GenericFile<Object>> list = Collections.emptyList();
 
         Exception ex = assertThrows(GenericFileOperationFailedException.class,
-                () -> consumer.doSafePollSubDirectory("anyPath", "adir", list, 
0));
+                () -> consumer.doSafePollSubDirectory(null, "anyPath", "adir", 
list, 0));
 
         assertNull(ex.getCause());
     }
@@ -113,6 +113,7 @@ public class RemoteFileIgnoreDoPollErrorTest {
         return new RemoteFileConsumer<>(remoteFileEndpoint, null, null, null) {
             @Override
             protected boolean doPollDirectory(
+                    Exchange dynamic,
                     String absolutePath, String dirName, 
List<GenericFile<Object>> genericFiles, int depth) {
                 if ("IllegalStateException".equals(doPollResult)) {
                     throw new IllegalStateException("Problem");
@@ -124,7 +125,8 @@ public class RemoteFileIgnoreDoPollErrorTest {
             }
 
             @Override
-            protected boolean pollDirectory(String fileName, 
List<GenericFile<Object>> genericFiles, int depth) {
+            protected boolean pollDirectory(
+                    Exchange dynamic, String fileName, 
List<GenericFile<Object>> genericFiles, int depth) {
                 return false;
             }
 
diff --git 
a/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbConsumer.java
 
b/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbConsumer.java
index d7131ff6cbe..2ae5bab54ff 100644
--- 
a/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbConsumer.java
+++ 
b/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbConsumer.java
@@ -68,7 +68,8 @@ public class SmbConsumer extends 
GenericFileConsumer<FileIdBothDirectoryInformat
     }
 
     @Override
-    protected boolean pollDirectory(String path, 
List<GenericFile<FileIdBothDirectoryInformation>> fileList, int depth) {
+    protected boolean pollDirectory(
+            Exchange dynamic, String path, 
List<GenericFile<FileIdBothDirectoryInformation>> fileList, int depth) {
         depth++;
         path = (path == null) ? "" : path;
         FileIdBothDirectoryInformation[] files = getSmbFiles(path);
@@ -96,7 +97,7 @@ public class SmbConsumer extends 
GenericFileConsumer<FileIdBothDirectoryInformat
                         = path + (path.endsWith("/") ? "" : "/") + 
file.getFileName();
             }
 
-            if (handleSmbEntries(fullFilePath, fileList, depth, files, file)) {
+            if (handleSmbEntries(dynamic, fullFilePath, fileList, depth, 
files, file)) {
                 return false;
             }
         }
@@ -109,20 +110,22 @@ public class SmbConsumer extends 
GenericFileConsumer<FileIdBothDirectoryInformat
     }
 
     private boolean handleSmbEntries(
+            Exchange dynamic,
             String fullFilePath, 
List<GenericFile<FileIdBothDirectoryInformation>> fileList, int depth,
             FileIdBothDirectoryInformation[] files, 
FileIdBothDirectoryInformation file) {
 
         if (isDirectory(file)) {
             LOG.trace("SmbFile[name={}, dir=true]", file.getFileName());
-            return handleDirectory(fullFilePath, fileList, depth, files, file);
+            return handleDirectory(dynamic, fullFilePath, fileList, depth, 
files, file);
         } else {
             LOG.trace("SmbFile[name={}, file=true]", file.getFileName());
-            handleFile(fullFilePath, fileList, depth, files, file);
+            handleFile(dynamic, fullFilePath, fileList, depth, files, file);
         }
         return false;
     }
 
     private boolean handleDirectory(
+            Exchange dynamic,
             String fullFilePath, 
List<GenericFile<FileIdBothDirectoryInformation>> fileList, int depth,
             FileIdBothDirectoryInformation[] files, 
FileIdBothDirectoryInformation file) {
 
@@ -130,10 +133,10 @@ public class SmbConsumer extends 
GenericFileConsumer<FileIdBothDirectoryInformat
             SmbFile smbFile = asGenericFile(fullFilePath, file, 
getEndpoint().getCharset());
             Supplier<GenericFile<FileIdBothDirectoryInformation>> 
genericFileSupplier = Suppliers.memorize(() -> smbFile);
             Supplier<String> relativePath = smbFile::getRelativeFilePath;
-            if (isValidFile(genericFileSupplier, file.getFileName(),
+            if (isValidFile(dynamic, genericFileSupplier, file.getFileName(),
                     smbFile.getAbsoluteFilePath(), relativePath, true, files)) 
{
                 // recursive scan and add the sub files and folders
-                boolean canPollMore = pollDirectory(fullFilePath, fileList, 
depth);
+                boolean canPollMore = pollDirectory(dynamic, fullFilePath, 
fileList, depth);
                 return !canPollMore;
             }
         }
@@ -141,6 +144,7 @@ public class SmbConsumer extends 
GenericFileConsumer<FileIdBothDirectoryInformat
     }
 
     private void handleFile(
+            Exchange dynamic,
             String fullFilePath, 
List<GenericFile<FileIdBothDirectoryInformation>> fileList, int depth,
             FileIdBothDirectoryInformation[] files, 
FileIdBothDirectoryInformation file) {
 
@@ -149,7 +153,7 @@ public class SmbConsumer extends 
GenericFileConsumer<FileIdBothDirectoryInformat
             Supplier<GenericFile<FileIdBothDirectoryInformation>> 
genericFileSupplier = Suppliers.memorize(() -> smbFile);
             Supplier<String> relativePath = smbFile::getRelativeFilePath;
 
-            if (isValidFile(genericFileSupplier, file.getFileName(),
+            if (isValidFile(dynamic, genericFileSupplier, file.getFileName(),
                     smbFile.getAbsoluteFilePath(), relativePath, false, 
files)) {
                 fileList.add(smbFile);
             }
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
index 5fbdc56df6f..53e8c08fcdb 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
@@ -12096,6 +12096,7 @@ public final class ModelDeserializers extends 
YamlDeserializerSupport {
                     @YamlProperty(name = "aggregationStrategy", type = 
"string", description = "Sets the AggregationStrategy to be used to merge the 
reply from the external service, into a single outgoing message. By default 
Camel will use the reply from the external service as outgoing message.", 
displayName = "Aggregation Strategy"),
                     @YamlProperty(name = "aggregationStrategyMethodAllowNull", 
type = "string", description = "If this option is false then the aggregate 
method is not used if there was no data to enrich. If this option is true then 
null values is used as the oldExchange (when no data to enrich), when using 
POJOs as the AggregationStrategy.", displayName = "Aggregation Strategy Method 
Allow Null"),
                     @YamlProperty(name = "aggregationStrategyMethodName", type 
= "string", description = "This option can be used to explicit declare the 
method name to use, when using POJOs as the AggregationStrategy.", displayName 
= "Aggregation Strategy Method Name"),
+                    @YamlProperty(name = "allowOptimisedComponents", type = 
"boolean", description = "Whether to allow components to optimise if they are 
org.apache.camel.spi.SendDynamicAware .", displayName = "Allow Optimised 
Components"),
                     @YamlProperty(name = "autoStartComponents", type = 
"boolean", description = "Whether to auto startup components when poll enricher 
is starting up.", displayName = "Auto Start Components"),
                     @YamlProperty(name = "cacheSize", type = "number", 
description = "Sets the maximum size used by the 
org.apache.camel.spi.ConsumerCache which is used to cache and reuse consumers 
when uris are reused. Beware that when using dynamic endpoints then it affects 
how well the cache can be utilized. If each dynamic endpoint is unique then its 
best to turn off caching by setting this to -1, which allows Camel to not cache 
both the producers and endpoints; they are regarded as  [...]
                     @YamlProperty(name = "description", type = "string", 
description = "Sets the description of this node", displayName = "Description"),
@@ -12142,6 +12143,11 @@ public final class ModelDeserializers extends 
YamlDeserializerSupport {
                     target.setAggregationStrategyMethodName(val);
                     break;
                 }
+                case "allowOptimisedComponents": {
+                    String val = asText(node);
+                    target.setAllowOptimisedComponents(val);
+                    break;
+                }
                 case "autoStartComponents": {
                     String val = asText(node);
                     target.setAutoStartComponents(val);
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
index 7deecd56aaf..c69e1e12d76 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
@@ -4108,6 +4108,11 @@
             "title" : "Aggregation Strategy Method Name",
             "description" : "This option can be used to explicit declare the 
method name to use, when using POJOs as the AggregationStrategy."
           },
+          "allowOptimisedComponents" : {
+            "type" : "boolean",
+            "title" : "Allow Optimised Components",
+            "description" : "Whether to allow components to optimise if they 
are org.apache.camel.spi.SendDynamicAware ."
+          },
           "autoStartComponents" : {
             "type" : "boolean",
             "title" : "Auto Start Components",


Reply via email to