public void onRegister()

in services/minho-config-json/src/main/java/org/apache/karaf/minho/config/json/JsonConfigLoaderService.java [48:74]


    public void onRegister(final ServiceRegistry serviceRegistry) throws Exception {
        Config config = null;
        File minhoJson = new File("./minho.json");
        if (System.getenv("MINHO_CONFIG") != null) {
            log.info("Loading JSON configuration from MINHO_CONFIG env variable");
            StringReader reader = new StringReader(System.getenv("MINHO_CONFIG"));
            config = loadJson(new StringReader(System.getenv("MINHO_CONFIG")));
        } else if (System.getenv("MINHO_CONFIG_FILE") != null) {
            log.info("Loading JSON configuration from " + System.getenv("MINHO_CONFIG_FILE"));
            config = loadJson(new FileInputStream(System.getenv("MINHO_CONFIG_FILE")));
        } else if (System.getProperty("minho.config") != null) {
            log.info("Loading JSON configuration from " + System.getProperty("minho.config"));
            config = loadJson(new FileInputStream(System.getProperty("minho.config")));
        } else if (JsonConfigLoaderService.class.getResourceAsStream("/META-INF/minho.json") != null) {
            log.info("Loading JSON configuration from classpath META-INF/minho.json");
            config = loadJson(JsonConfigLoaderService.class.getResourceAsStream("/META-INF/minho.json"));
        } else if (JsonConfigLoaderService.class.getResourceAsStream("/minho.json") != null) {
            log.info("Loading JSON configuration from classpath minho.json");
            config = loadJson(JsonConfigLoaderService.class.getResourceAsStream("/minho.json"));
        } else if (minhoJson.exists()) {
            log.info("Loading JSON configuration from current directory: ./minho.json");
            config = loadJson(new FileReader(minhoJson));
        }

        final var existing = serviceRegistry.get(Config.class);
        existing.merge(config);
    }