/** * Create a new {@link CompositeHealthIndicator} from the specified indicators. * @param healthAggregator the health aggregator * @param indicators a map of {@link HealthIndicator HealthIndicators} with the key * being used as an indicator name. */ public CompositeHealthIndicator(HealthAggregator healthAggregator, Map<String, HealthIndicator> indicators) { this(healthAggregator, new DefaultHealthIndicatorRegistry(indicators)); }
/** * Create a new {@link CompositeHealthIndicator}. * @param healthAggregator the health aggregator * @deprecated since 2.1.0 in favor of * {@link #CompositeHealthIndicator(HealthAggregator, HealthIndicatorRegistry)} */ @Deprecated public CompositeHealthIndicator(HealthAggregator healthAggregator) { this(healthAggregator, new DefaultHealthIndicatorRegistry()); }
/** * Create a {@link HealthIndicatorRegistry} based on the specified health indicators. * @param healthIndicators the {@link HealthIndicator} instances mapped by name * @return a {@link HealthIndicator} that delegates to the specified * {@code healthIndicators}. */ public HealthIndicatorRegistry createHealthIndicatorRegistry( Map<String, HealthIndicator> healthIndicators) { Assert.notNull(healthIndicators, "HealthIndicators must not be null"); return initialize(new DefaultHealthIndicatorRegistry(), healthIndicators); }
@Bean @ConditionalOnMissingBean(name = "bindersHealthIndicator") public CompositeHealthIndicator bindersHealthIndicator() { return new CompositeHealthIndicator(new OrderedHealthAggregator(), new DefaultHealthIndicatorRegistry()); }
protected HealthIndicator createHealthIndicator(Map<String, S> beans) { if (beans.size() == 1) { return createHealthIndicator(beans.values().iterator().next()); } HealthIndicatorRegistry registry = new DefaultHealthIndicatorRegistry(); beans.forEach( (name, source) -> registry.register(name, createHealthIndicator(source))); return new CompositeHealthIndicator(this.healthAggregator, registry); }