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

com.datastax.astra.boot.utils.SdkConfigSupplierSpring Maven / Gradle / Ivy

There is a newer version: 1.2.9
Show newest version
package com.datastax.astra.boot.utils;

import java.util.Map;
import java.util.function.Supplier;

import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;

/**
 * Introducing application.yaml in the configuration.
 */
public class SdkConfigSupplierSpring  implements Supplier {

    /** Reference to Spring keys. */
    private final Map springKeys;
    
    /**
     * Constructor.
     *
     * @param springKeys
     *      hold reference for keys;
     */
    public SdkConfigSupplierSpring(Map springKeys) {
        this.springKeys = springKeys;
    }
    
    /** {@inheritDoc} */
    @Override
    public Config get() {
        ConfigFactory.invalidateCaches();
        return ConfigFactory.defaultOverrides()
                .withFallback(ConfigFactory.parseMap(springKeys, "Spring properties"))
                .withFallback(ConfigFactory.parseResources("application.conf"))
                .withFallback(ConfigFactory.parseResources("application.json"))
                .withFallback(ConfigFactory.defaultReference())
                .resolve();
    }
    

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy