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

org.zodiac.autoconfigure.scc.client.SpringCloudClientBootstrapConfiguration Maven / Gradle / Ivy

There is a newer version: 1.6.8
Show newest version
package org.zodiac.autoconfigure.scc.client;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.zodiac.autoconfigure.bootstrap.condition.ConditionalOnSpringCloudBootstrapDisabled;
import org.zodiac.autoconfigure.bootstrap.config.client.HttpAppConfigClientProperties;
import org.zodiac.autoconfigure.scc.client.condition.ConditionalOnSpringCloudAppConfigClientEnabled;
import org.zodiac.scc.client.SpringCloudConfigPropertySourceLocator;

@SpringBootConfiguration
@ConditionalOnSpringCloudBootstrapDisabled
@ConditionalOnSpringCloudAppConfigClientEnabled
public class SpringCloudClientBootstrapConfiguration {

    private Environment environment;
    private HttpAppConfigClientProperties httpAppConfigClientProperties;

    public SpringCloudClientBootstrapConfiguration(Environment environment,
        ObjectProvider httpAppConfigClientProperties) {
        this.environment = environment;
        this.httpAppConfigClientProperties = httpAppConfigClientProperties.getIfAvailable();
    }

    @Bean
    @ConfigurationProperties(prefix = org.zodiac.scc.client.constants.SpringConfigClientSystemPropertiesConstants.SPRING_BOOTSTRAP_CONFIG_SPRING_CLOUD_PREFIX, ignoreInvalidFields = true)
    protected SpringCloudAppConfigClientProperties springCloudAppConfigClientProperties() {
        SpringCloudAppConfigClientProperties properties = new SpringCloudAppConfigClientProperties(environment);
        if (null != httpAppConfigClientProperties)
            BeanUtils.copyProperties(httpAppConfigClientProperties, properties);
        return properties;
    }

    @Bean
    @ConditionalOnMissingBean
    protected SpringCloudConfigPropertySourceLocator configServicePropertySource(
        SpringCloudAppConfigClientProperties springCloudAppConfigClientProperties) {
        SpringCloudConfigPropertySourceLocator locator = new SpringCloudConfigPropertySourceLocator(
            springCloudAppConfigClientProperties);
        return locator;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy