use of org.apache.camel.quarkus.core.deployment.util.CamelSupport in project camel-quarkus by apache.
the class MicroProfileHealthProcessor method camelHealthDiscovery.
@BuildStep(onlyIf = HealthEnabled.class)
List<CamelBeanBuildItem> camelHealthDiscovery(CombinedIndexBuildItem combinedIndex) {
IndexView index = combinedIndex.getIndex();
List<CamelBeanBuildItem> buildItems = new ArrayList<>();
Collection<ClassInfo> healthChecks = index.getAllKnownImplementors(CAMEL_HEALTH_CHECK_DOTNAME);
Collection<ClassInfo> healthCheckRepositories = index.getAllKnownImplementors(CAMEL_HEALTH_CHECK_REPOSITORY_DOTNAME);
Config config = ConfigProvider.getConfig();
Predicate<ClassInfo> healthCheckFilter = classInfo -> {
String className = classInfo.name().toString();
if (className.equals(HealthCheckRegistryRepository.class.getName())) {
// HealthCheckRegistryRepository is created internally by Camel
return false;
}
if (className.equals(ContextHealthCheck.class.getName())) {
return config.getOptionalValue("camel.health.contextEnabled", boolean.class).orElse(true);
}
if (className.equals(RoutesHealthCheckRepository.class.getName())) {
return config.getOptionalValue("camel.health.routesEnabled", boolean.class).orElse(true);
}
if (className.equals(ConsumersHealthCheckRepository.class.getName())) {
return config.getOptionalValue("camel.health.consumersEnabled", boolean.class).orElse(true);
}
return true;
};
// Create CamelBeanBuildItem to bind instances of HealthCheck to the camel registry
healthChecks.stream().filter(CamelSupport::isConcrete).filter(CamelSupport::isPublic).filter(ClassInfo::hasNoArgsConstructor).filter(healthCheckFilter).map(this::createHealthCamelBeanBuildItem).forEach(buildItems::add);
// Create CamelBeanBuildItem to bind instances of HealthCheckRepository to the camel registry
healthCheckRepositories.stream().filter(CamelSupport::isConcrete).filter(CamelSupport::isPublic).filter(ClassInfo::hasNoArgsConstructor).filter(healthCheckFilter).map(this::createHealthCamelBeanBuildItem).forEach(buildItems::add);
return buildItems;
}
use of org.apache.camel.quarkus.core.deployment.util.CamelSupport in project camel-quarkus by apache.
the class Hl7Processor method registerForReflection.
@BuildStep
void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, CombinedIndexBuildItem combinedIndex) {
IndexView index = combinedIndex.getIndex();
// Register hapi model types for reflection
String[] hapiStructureClasses = index.getAllKnownImplementors(DotName.createSimple(Structure.class.getName())).stream().map(classInfo -> classInfo.name().toString()).toArray(String[]::new);
String[] hapiTypeClasses = index.getAllKnownImplementors(DotName.createSimple(Type.class.getName())).stream().map(classInfo -> classInfo.name().toString()).toArray(String[]::new);
reflectiveClass.produce(new ReflectiveClassBuildItem(false, true, hapiStructureClasses));
reflectiveClass.produce(new ReflectiveClassBuildItem(false, true, hapiTypeClasses));
// Beans that have the Hl7Terser annotation require reflective access
String[] terserBeans = index.getAnnotations(DotName.createSimple(Hl7Terser.class.getName())).stream().map(AnnotationInstance::target).map(annotationTarget -> {
if (annotationTarget.kind().equals(AnnotationTarget.Kind.FIELD)) {
return annotationTarget.asType().asClass();
} else if (annotationTarget.kind().equals(AnnotationTarget.Kind.METHOD)) {
return annotationTarget.asMethod().declaringClass();
} else if (annotationTarget.kind().equals(AnnotationTarget.Kind.METHOD_PARAMETER)) {
return annotationTarget.asMethodParameter().method().declaringClass();
}
return null;
}).filter(CamelSupport::isConcrete).map(classInfo -> classInfo.name().toString()).toArray(String[]::new);
reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, terserBeans));
}
use of org.apache.camel.quarkus.core.deployment.util.CamelSupport in project camel-quarkus by apache.
the class ZendeskProcessor method registerForReflection.
@BuildStep
ReflectiveClassBuildItem registerForReflection(CombinedIndexBuildItem combinedIndex) {
IndexView index = combinedIndex.getIndex();
String[] zendeskModelClasses = index.getKnownClasses().stream().filter(CamelSupport::isConcrete).map(classInfo -> classInfo.name().toString()).filter(className -> className.startsWith("org.zendesk.client.v2.model")).toArray(String[]::new);
return new ReflectiveClassBuildItem(true, false, zendeskModelClasses);
}
use of org.apache.camel.quarkus.core.deployment.util.CamelSupport 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)));
}
use of org.apache.camel.quarkus.core.deployment.util.CamelSupport in project camel-quarkus by apache.
the class ServicenowProcessor method registerForReflection.
@BuildStep
void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, CombinedIndexBuildItem combinedIndex) {
IndexView index = combinedIndex.getIndex();
// Get candidate DTOs annotated with ServiceNowSysParm
String[] serviceNowDtos = index.getAnnotations(DotName.createSimple(ServiceNowSysParm.class.getName())).stream().map(AnnotationInstance::target).filter(annotationTarget -> annotationTarget.kind().equals(AnnotationTarget.Kind.CLASS)).map(AnnotationTarget::asClass).filter(CamelSupport::isConcrete).filter(CamelSupport::isPublic).map(classInfo -> classInfo.name().toString()).filter(className -> !className.startsWith("org.apache.camel.component.servicenow.model")).toArray(String[]::new);
reflectiveClass.produce(new ReflectiveClassBuildItem(false, true, serviceNowDtos));
reflectiveClass.produce(new ReflectiveClassBuildItem(false, true, HTTPTransportFactory.class, ServiceNowExceptionModel.class));
}
Aggregations