protected HealthIndicator createHealthIndicator(Map<String, S> beans) {
   if (beans.size() == 1) {
     return createHealthIndicator(beans.values().iterator().next());
   }
   CompositeHealthIndicator composite = new CompositeHealthIndicator(this.healthAggregator);
   for (Map.Entry<String, S> entry : beans.entrySet()) {
     composite.addHealthIndicator(entry.getKey(), createHealthIndicator(entry.getValue()));
   }
   return composite;
 }
  @Override
  public void afterPropertiesSet() throws Exception {

    final Map<String, HealthIndicator> healthIndicators =
        applicationContext.getBeansOfType(HealthIndicator.class);
    for (Map.Entry<String, HealthIndicator> entry : healthIndicators.entrySet()) {
      healthIndicator.addHealthIndicator(entry.getKey(), entry.getValue());
    }
  }
  @Override
  public void afterPropertiesSet() throws Exception {
    final Map<String, HealthIndicator> healthIndicators =
        applicationContext.getBeansOfType(HealthIndicator.class);

    for (Map.Entry<String, HealthIndicator> entry : healthIndicators.entrySet()) {

      // ignore EurekaHealthIndicator and flatten the rest of the composite
      // otherwise there is a never ending cycle of down. See gh-643
      if (entry.getValue() instanceof DiscoveryCompositeHealthIndicator) {
        DiscoveryCompositeHealthIndicator indicator =
            (DiscoveryCompositeHealthIndicator) entry.getValue();
        for (DiscoveryCompositeHealthIndicator.Holder holder : indicator.getHealthIndicators()) {
          if (!(holder.getDelegate() instanceof EurekaHealthIndicator)) {
            healthIndicator.addHealthIndicator(holder.getDelegate().getName(), holder);
          }
        }

      } else {
        healthIndicator.addHealthIndicator(entry.getKey(), entry.getValue());
      }
    }
  }
 protected InstanceStatus getHealthStatus() {
   final Status status = healthIndicator.health().getStatus();
   return mapToInstanceStatus(status);
 }