use of org.apache.camel.health.HealthCheckRepository 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;
}
Aggregations