public static Stream services()

in extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/util/CamelSupport.java [60:93]


    public static Stream<CamelServiceBuildItem> services(ApplicationArchivesBuildItem archives, PathFilter pathFilter) {
        final Set<CamelServiceBuildItem> answer = new HashSet<>();
        final Predicate<Path> filter = pathFilter.asPathPredicate();

        for (ApplicationArchive archive : archives.getAllApplicationArchives()) {
            for (Path root : archive.getRootDirectories()) {
                final Path resourcePath = root.resolve(CAMEL_SERVICE_BASE_PATH);

                if (!Files.isDirectory(resourcePath)) {
                    continue;
                }

                try (Stream<Path> files = Files.walk(resourcePath)) {
                    files.filter(Files::isRegularFile).forEach(file -> {
                        // the root archive may point to a jar file or the absolute path of
                        // a project's build output so we need to relativize to make the
                        // FastFactoryFinder work as expected
                        Path key = root.relativize(file);

                        if (filter.test(key)) {
                            String clazz = readProperties(file).getProperty("class");
                            if (clazz != null) {
                                answer.add(new CamelServiceBuildItem(key, clazz));
                            }
                        }
                    });
                } catch (IOException e) {
                    throw new RuntimeException("Could not walk " + resourcePath, e);
                }
            }
        }

        return answer.stream();
    }