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

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


The following commit(s) were added to refs/heads/main by this push:
     new dcfd0e7  CAMEL-16662: camel-spring-boot - Add fatjar package scan 
resource loaded that can load inside spring boot fat-jars
dcfd0e7 is described below

commit dcfd0e7df0e6667e0ddf66d2de760886259204df
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Wed Jun 2 10:01:37 2021 +0200

    CAMEL-16662: camel-spring-boot - Add fatjar package scan resource loaded 
that can load inside spring boot fat-jars
---
 .../engine/DefaultPackageScanResourceResolver.java | 40 ++++++++++++++--------
 1 file changed, 26 insertions(+), 14 deletions(-)

diff --git 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultPackageScanResourceResolver.java
 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultPackageScanResourceResolver.java
index ea775c0..acefea6 100644
--- 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultPackageScanResourceResolver.java
+++ 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultPackageScanResourceResolver.java
@@ -227,16 +227,38 @@ public class DefaultPackageScanResourceResolver extends 
BasePackageScanResolver
      * Finds matching classes within a jar files that contains a folder 
structure matching the package structure. If the
      * File is not a JarFile or does not exist a warning will be logged, but 
no error will be raised.
      *
-     * @param stream  the inputstream of the jar file to be examined for 
classes
-     * @param urlPath the url of the jar file to be examined for classes
+     * @param packageName the root package name
+     * @param subPattern  optional pattern to use for matching resource names
+     * @param stream      the inputstream of the jar file to be examined for 
classes
+     * @param urlPath     the url of the jar file to be examined for classes
+     * @param resources   the list to add loaded resources
      */
-    private void loadImplementationsInJar(
+    protected void loadImplementationsInJar(
             String packageName,
             String subPattern,
             InputStream stream,
             String urlPath,
             Set<Resource> resources) {
 
+        List<String> entries = doLoadImplementationsInJar(packageName, stream, 
urlPath);
+        for (String name : entries) {
+            String shortName = name.substring(packageName.length());
+            boolean match = PATH_MATCHER.match(subPattern, shortName);
+            log.debug("Found resource: {} matching pattern: {} -> {}", 
shortName, subPattern, match);
+            if (match) {
+                final ExtendedCamelContext ecc = 
getCamelContext().adapt(ExtendedCamelContext.class);
+                final ResourceLoader loader = ecc.getResourceLoader();
+
+                resources.add(loader.resolveResource(name));
+            }
+        }
+    }
+
+    protected List<String> doLoadImplementationsInJar(
+            String packageName,
+            InputStream stream,
+            String urlPath) {
+
         List<String> entries = new ArrayList<>();
 
         JarInputStream jarStream = null;
@@ -262,17 +284,7 @@ public class DefaultPackageScanResourceResolver extends 
BasePackageScanResolver
             IOHelper.close(jarStream, urlPath, log);
         }
 
-        for (String name : entries) {
-            String shortName = name.substring(packageName.length());
-            boolean match = PATH_MATCHER.match(subPattern, shortName);
-            log.debug("Found resource: {} matching pattern: {} -> {}", 
shortName, subPattern, match);
-            if (match) {
-                final ExtendedCamelContext ecc = 
getCamelContext().adapt(ExtendedCamelContext.class);
-                final ResourceLoader loader = ecc.getResourceLoader();
-
-                resources.add(loader.resolveResource(name));
-            }
-        }
+        return entries;
     }
 
     /**

Reply via email to