/** * Create a {@link CompositeHealthIndicator} based on the specified health indicators. * @param healthAggregator the {@link HealthAggregator} * @param healthIndicators the {@link HealthIndicator} instances mapped by name * @return a {@link HealthIndicator} that delegates to the specified * {@code healthIndicators}. */ public CompositeHealthIndicator createHealthIndicator( HealthAggregator healthAggregator, Map<String, HealthIndicator> healthIndicators) { Assert.notNull(healthAggregator, "HealthAggregator must not be null"); Assert.notNull(healthIndicators, "HealthIndicators must not be null"); HealthIndicatorRegistryFactory factory = new HealthIndicatorRegistryFactory( this.healthIndicatorNameFactory); return new CompositeHealthIndicator(healthAggregator, factory.createHealthIndicatorRegistry(healthIndicators)); }
/** * 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); }
public static HealthIndicatorRegistry get(ApplicationContext applicationContext) { Map<String, HealthIndicator> indicators = new LinkedHashMap<>(); indicators.putAll(applicationContext.getBeansOfType(HealthIndicator.class)); if (ClassUtils.isPresent("reactor.core.publisher.Flux", null)) { new ReactiveHealthIndicators().get(applicationContext) .forEach(indicators::putIfAbsent); } HealthIndicatorRegistryFactory factory = new HealthIndicatorRegistryFactory(); return factory.createHealthIndicatorRegistry(indicators); }