ppalaga commented on a change in pull request #358: Fix #136 @ConfigProperty
and @Inject do not work in RouteBuilders
URL: https://github.com/apache/camel-quarkus/pull/358#discussion_r344890711
##########
File path:
extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
##########
@@ -249,17 +262,55 @@ CamelRuntimeRegistryBuildItem bindRuntimeBeansToRegistry(
* disabled by setting quarkus.camel.disable-main = true
*/
public static class Main {
+
+ @BuildStep
+ public List<CamelRoutesBuilderClassBuildItem>
discoverRoutesBuilderClassNames(
+ CombinedIndexBuildItem combinedIndex) {
+ final IndexView index = combinedIndex.getIndex();
+ Set<ClassInfo> allKnownImplementors = new HashSet<>();
+ allKnownImplementors.addAll(
+
index.getAllKnownImplementors(DotName.createSimple(RoutesBuilder.class.getName())));
+ allKnownImplementors.addAll(
+
index.getAllKnownSubclasses(DotName.createSimple(RouteBuilder.class.getName())));
+ allKnownImplementors.addAll(
+
index.getAllKnownSubclasses(DotName.createSimple(AdviceWithRouteBuilder.class.getName())));
+
+ return allKnownImplementors
+ .stream()
+ // public and non-abstract
+ .filter(ci -> ((ci.flags() & (Modifier.ABSTRACT |
Modifier.PUBLIC)) == Modifier.PUBLIC))
+ .map(ClassInfo::name)
+ .map(CamelRoutesBuilderClassBuildItem::new)
+ .collect(Collectors.toList());
+ }
+
@Record(ExecutionTime.STATIC_INIT)
@BuildStep
- public List<CamelRoutesBuilderBuildItem> collectRoutes(
- CombinedIndexBuildItem combinedIndex,
+ public List<CamelBeanBuildItem> collectRoutes(
+ List<CamelRoutesBuilderClassBuildItem> camelRoutesBuilders,
CamelMainRecorder recorder,
+ BeanRegistrationPhaseBuildItem beanRegistrationPhase,
RecorderContext recorderContext) {
- return
CamelSupport.getRouteBuilderClasses(combinedIndex.getIndex())
- .map(recorderContext::<RoutesBuilder> newInstance)
- .map(CamelRoutesBuilderBuildItem::new)
- .collect(Collectors.toList());
+ final Set<DotName> arcBeanClasses =
beanRegistrationPhase.getContext().get(BuildExtension.Key.BEANS)
+ .stream()
+ .map(BeanInfo::getImplClazz)
+ .map(ClassInfo::name)
+ .collect(Collectors.toSet());
+
+ final List<CamelBeanBuildItem> result = new
ArrayList<CamelBeanBuildItem>();
+ camelRoutesBuilders.stream()
+ .map(CamelRoutesBuilderClassBuildItem::getDotName)
+ .filter(dotName -> !arcBeanClasses.contains(dotName))
+ .forEach(dotName -> {
Review comment:
Yeah, that would be possible now. The previous revisions did not allow that.
Let me refactor.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services