protected List doLoadImplementationsInJar()

in core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/FatJarPackageScanResourceResolver.java [49:83]


    protected List<String> doLoadImplementationsInJar(String packageName, InputStream stream, String urlPath,
                                                      boolean inspectNestedJars, boolean closeStream) {
        List<String> entries = new ArrayList<>();

        JarInputStream jarStream = null;
        try {
            jarStream = new JarInputStream(stream);

            JarEntry entry;
            while ((entry = jarStream.getNextJarEntry()) != null) {
                String name = entry.getName().trim();
                if (inspectNestedJars && !entry.isDirectory() && isSpringBootNestedJar(name)) {
                    String nestedUrl = urlPath + "!/" + name;
                    LOG.trace("Inspecting nested jar: {}", nestedUrl);
                    List<String> nestedEntries = doLoadImplementationsInJar(packageName, jarStream, nestedUrl, false, false);
                    entries.addAll(nestedEntries);
                } else if (!entry.isDirectory() && !name.endsWith(".class")) {
                    name = cleanupSpringBootClassName(name);
                    // name is FQN so it must start with package name
                    if (name.startsWith(packageName)) {
                        entries.add(name);
                    }
                }
            }
        } catch (IOException ioe) {
            LOG.warn("Cannot search jar file '" + urlPath + " due to an IOException: " + ioe.getMessage() + ". This exception is ignored.", ioe);
        } finally {
            if (closeStream) {
                // stream is left open when scanning nested jars, otherwise the fat jar stream gets closed
                IOHelper.close(jarStream, urlPath, LOG);
            }
        }

        return entries;
    }