in core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/CamelHealthCheckAutoConfiguration.java [53:142]
public HealthIndicator camelHealthCheckIndicator(ApplicationContext applicationContext,
CamelContext camelContext, CamelHealthCheckConfigurationProperties config) {
if (config != null && config.getEnabled() != null && !config.getEnabled()) {
// health check is disabled
return null;
}
if (config == null) {
config = new CamelHealthCheckConfigurationProperties();
}
// auto-detect camel-health on classpath
HealthCheckRegistry hcr = camelContext.getCamelContextExtension()
.getContextPlugin(HealthCheckRegistry.class);
if (hcr == null) {
if (config.getEnabled() != null && config.getEnabled()) {
LOG.warn("Cannot find HealthCheckRegistry from classpath. Add camel-health to classpath.");
}
return null;
}
// lets signal we are integrated with spring boot
hcr.setId("camel-spring-boot");
if (config.getEnabled() != null) {
hcr.setEnabled(config.getEnabled());
}
if (config.getExcludePattern() != null) {
hcr.setExcludePattern(config.getExcludePattern());
}
if (config.getExposureLevel() != null) {
hcr.setExposureLevel(config.getExposureLevel());
}
if (config.getInitialState() != null) {
hcr.setInitialState(
camelContext.getTypeConverter().convertTo(HealthCheck.State.class, config.getInitialState()));
}
// context is enabled by default
if (hcr.isEnabled()) {
HealthCheck hc = (HealthCheck) hcr.resolveById("context");
if (hc != null) {
hcr.register(hc);
}
}
// routes are enabled by default
if (hcr.isEnabled()) {
HealthCheckRepository hc = hcr.getRepository("routes")
.orElse((HealthCheckRepository) hcr.resolveById("routes"));
if (hc != null) {
if (config.getRoutesEnabled() != null) {
hc.setEnabled(config.getRoutesEnabled());
}
hcr.register(hc);
}
}
// producers are disabled by default
if (hcr.isEnabled()) {
HealthCheckRepository hc = hcr.getRepository("producers")
.orElse((HealthCheckRepository) hcr.resolveById("producers"));
if (hc != null) {
if (config.getProducersEnabled() != null) {
hc.setEnabled(config.getProducersEnabled());
}
hcr.register(hc);
}
}
// consumers are enabled by default
if (hcr.isEnabled()) {
HealthCheckRepository hc = hcr.getRepository("consumers")
.orElse((HealthCheckRepository) hcr.resolveById("consumers"));
if (hc != null) {
if (config.getConsumersEnabled() != null) {
hc.setEnabled(config.getConsumersEnabled());
}
hcr.register(hc);
}
}
// registry are enabled by default
if (hcr.isEnabled()) {
HealthCheckRepository hc = hcr.getRepository("registry")
.orElse((HealthCheckRepository) hcr.resolveById("registry"));
if (hc != null) {
if (config.getRegistryEnabled() != null) {
hc.setEnabled(config.getRegistryEnabled());
}
hcr.register(hc);
}
}
return new CamelHealthCheckIndicator(applicationContext, camelContext, config.getExposureLevel());
}