Search in sources :

Example 1 with RoutesBuilderClassExcludeBuildItem

use of org.apache.camel.quarkus.core.deployment.spi.RoutesBuilderClassExcludeBuildItem in project camel-quarkus by apache.

the class CamelProcessor method discoverRoutesBuilderClassNames.

@BuildStep(onlyIf = { CamelConfigFlags.RoutesDiscoveryEnabled.class })
public List<CamelRoutesBuilderClassBuildItem> discoverRoutesBuilderClassNames(CombinedIndexBuildItem combinedIndex, CamelConfig config, List<RoutesBuilderClassExcludeBuildItem> routesBuilderClassExcludes) {
    final IndexView index = combinedIndex.getIndex();
    Set<ClassInfo> allKnownImplementors = new HashSet<>();
    allKnownImplementors.addAll(index.getAllKnownImplementors(ROUTES_BUILDER_TYPE));
    allKnownImplementors.addAll(index.getAllKnownSubclasses(ROUTE_BUILDER_TYPE));
    allKnownImplementors.addAll(index.getAllKnownSubclasses(ADVICE_WITH_ROUTE_BUILDER_TYPE));
    final Predicate<DotName> pathFilter = new PathFilter.Builder().exclude(routesBuilderClassExcludes.stream().map(RoutesBuilderClassExcludeBuildItem::getPattern).collect(Collectors.toList())).exclude(config.routesDiscovery.excludePatterns).include(config.routesDiscovery.includePatterns).build().asDotNamePredicate();
    return allKnownImplementors.stream().filter(ci -> ((ci.flags() & (Modifier.ABSTRACT | Modifier.PUBLIC)) == Modifier.PUBLIC)).map(ClassInfo::name).filter(pathFilter).map(CamelRoutesBuilderClassBuildItem::new).collect(Collectors.toList());
}
Also used : PathFilter(org.apache.camel.quarkus.core.deployment.util.PathFilter) IndexView(org.jboss.jandex.IndexView) RoutesBuilderClassExcludeBuildItem(org.apache.camel.quarkus.core.deployment.spi.RoutesBuilderClassExcludeBuildItem) DotName(org.jboss.jandex.DotName) ClassInfo(org.jboss.jandex.ClassInfo) HashSet(java.util.HashSet) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Aggregations

BuildStep (io.quarkus.deployment.annotations.BuildStep)1 HashSet (java.util.HashSet)1 RoutesBuilderClassExcludeBuildItem (org.apache.camel.quarkus.core.deployment.spi.RoutesBuilderClassExcludeBuildItem)1 PathFilter (org.apache.camel.quarkus.core.deployment.util.PathFilter)1 ClassInfo (org.jboss.jandex.ClassInfo)1 DotName (org.jboss.jandex.DotName)1 IndexView (org.jboss.jandex.IndexView)1