use of io.quarkus.deployment.builditem.nativeimage.ReflectiveMethodBuildItem in project camel-quarkus by apache.
the class CamelNativeImageProcessor method reflectiveItems.
@BuildStep
void reflectiveItems(CombinedIndexBuildItem combinedIndex, BuildProducer<ReflectiveClassBuildItem> reflectiveClass, BuildProducer<ReflectiveMethodBuildItem> reflectiveMethod) {
final IndexView view = combinedIndex.getIndex();
CAMEL_REFLECTIVE_CLASSES.stream().map(Class::getName).map(DotName::createSimple).map(view::getAllKnownImplementors).flatMap(Collection::stream).filter(CamelSupport::isPublic).forEach(v -> reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, v.name().toString())));
DotName converter = DotName.createSimple(Converter.class.getName());
List<ClassInfo> converterClasses = view.getAnnotations(converter).stream().filter(ai -> ai.target().kind() == Kind.CLASS).filter(ai -> {
AnnotationValue av = ai.value("loader");
boolean isLoader = av != null && av.asBoolean();
// need to revisit with Camel 3.0.0-M3 which should improve this area
if (ai.target().asClass().name().toString().startsWith("org.apache.camel.converter.")) {
LOGGER.debug("Ignoring core " + ai + " " + ai.target().asClass().name());
return false;
} else if (isLoader) {
LOGGER.debug("Ignoring " + ai + " " + ai.target().asClass().name());
return false;
} else {
LOGGER.debug("Accepting " + ai + " " + ai.target().asClass().name());
return true;
}
}).map(ai -> ai.target().asClass()).collect(Collectors.toList());
LOGGER.debug("Converter classes: " + converterClasses);
converterClasses.forEach(ci -> reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, ci.name().toString())));
view.getAnnotations(converter).stream().filter(ai -> ai.target().kind() == Kind.METHOD).filter(ai -> converterClasses.contains(ai.target().asMethod().declaringClass())).map(ai -> ai.target().asMethod()).forEach(mi -> reflectiveMethod.produce(new ReflectiveMethodBuildItem(mi)));
}
Aggregations