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

org.zodiac.autoconfigure.apollo.ApolloClientBootstrapConfiguration Maven / Gradle / Ivy

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

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.zodiac.autoconfigure.apollo.condition.ConditionalOnApolloEnabled;
import org.zodiac.autoconfigure.bootstrap.condition.ConditionalOnSpringCloudBootstrapDisabled;

@SpringBootConfiguration
@ConditionalOnApolloEnabled
@ConditionalOnSpringCloudBootstrapDisabled
@ConditionalOnProperty(value = org.zodiac.apollo.sdk.constants.ApolloSystemPropertiesConstants.Zodiac.SPRING_BOOTSTRAP_CONFIG_APOLLO_ENABLED, havingValue = "true")
@ConditionalOnClass(name = {"com.ctrip.framework.apollo.ConfigService", "com.ctrip.framework.apollo.Apollo", "org.zodiac.apollo.config.client.ApolloAppPropertySourceLocator"})
public class ApolloClientBootstrapConfiguration {

    private Environment environment;

    public ApolloClientBootstrapConfiguration(Environment environment) {
        this.environment = environment;
    }

    @Bean
    @ConditionalOnMissingBean
    @ConfigurationProperties(prefix = org.zodiac.apollo.sdk.constants.ApolloSystemPropertiesConstants.Zodiac.SPRING_BOOTSTRAP_CONFIG_APOLLO_PREFIX, ignoreInvalidFields = true)
    protected ApolloAppConfigClientProperties apolloAppConfigClientProperties() {
        ApolloAppConfigClientProperties properties = new ApolloAppConfigClientProperties(environment);
        return properties;
    }

    @Bean
    @ConditionalOnMissingBean
    protected org.zodiac.apollo.client.config.ApolloAppPropertySourceLocator apolloAppPropertySourceLocator(
        ApolloAppConfigClientProperties apolloAppConfigClientProperties) {
        org.zodiac.apollo.client.config.ApolloAppPropertySourceLocator locator = new org.zodiac.apollo.client.config.ApolloAppPropertySourceLocator(apolloAppConfigClientProperties);
        return locator;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy