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

no.finn.archaius.ConstrettoConfigSource Maven / Gradle / Ivy

Go to download

Set up Constretto as a configuration source for Archaius. Typically for use with Hystrix.

The newest version!
package no.finn.archaius;

import com.netflix.config.PollResult;
import com.netflix.config.PolledConfigurationSource;
import org.constretto.ConstrettoConfiguration;
import org.constretto.Property;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * Trivial adapter for using Constretto as a backing configuration source for Archaius
 *
 * Henning Spjelkavik, FINN.no 2014
 *
 */
public class ConstrettoConfigSource implements PolledConfigurationSource {

    private final ConstrettoConfiguration config;

    public ConstrettoConfigSource(ConstrettoConfiguration config) {
        this.config = config;
    }

    @Override
    public PollResult poll(boolean initial, Object checkPoint) throws Exception {
        Map m = new HashMap();
        for (Property p : config) {
            m.put(p.getKey(), p.getValue());
        }
        return PollResult.createFull(m);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy