All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.stargate.health.BundleService Maven / Gradle / Ivy

There is a newer version: 2.1.0-BETA-19
Show newest version
package io.stargate.health;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BundleService {
  private static final Logger logger = LoggerFactory.getLogger(BundleService.class);

  private static final String HEALTH_NAME_HEADER = "x-Stargate-Health-Checkers";

  private final BundleContext context;

  public BundleService(BundleContext context) {
    this.context = context;
  }

  public Set defaultHealthCheckNames() {
    Set result = new HashSet<>();
    for (Bundle bundle : context.getBundles()) {
      String header = bundle.getHeaders().get(HEALTH_NAME_HEADER);
      if (header != null) {
        result.addAll(Arrays.asList(header.split(",")));
      }
    }

    return result;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy