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

com.bluetrainsoftware.common.config.SystemPropertiesConfigurationSource Maven / Gradle / Ivy

Go to download

Extends the functionality of Spring Boot and Sticky Code and provides extra support for Kubernetes style mounted volumes.

There is a newer version: 2.2
Show newest version
package com.bluetrainsoftware.common.config;


import net.stickycode.configuration.ConfigurationSource;
import net.stickycode.configuration.ConfigurationValue;
import net.stickycode.configuration.ResolvedConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SystemPropertiesConfigurationSource implements ConfigurationSource {
	private static final Logger log = LoggerFactory.getLogger(SystemPropertiesConfigurationSource.class);

  public SystemPropertiesConfigurationSource() {
    log.info("Sticky Configuration is ready to read from System Properties.");
  }

  @Override
	public void apply(net.stickycode.configuration.ConfigurationKey configurationKey, ResolvedConfiguration resolvedConfiguration) {
		final String key = configurationKey.join(".");

		final String value = System.getProperty(key);

		if (value != null) {
			resolvedConfiguration.add(new ConfigurationValue() {
				@Override
				public String get() {
					String newValue = System.getProperty(key);

          return newValue == null ? value : newValue;
				}

				@Override
				public boolean hasPrecedence(ConfigurationValue v) {
					return false;
				}
			});
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy