org.zodiac.autoconfigure.sentinel.datasource.SentinelNacosDataSourceAutoConfiguration Maven / Gradle / Ivy
package org.zodiac.autoconfigure.sentinel.datasource;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.zodiac.autoconfigure.bootstrap.condition.ConditionalOnSpringCloudBootstrapDisabled;
import org.zodiac.autoconfigure.sentinel.condition.ConditionalOnSentinelConfigEnabled;
@SpringBootConfiguration
@ConditionalOnSentinelConfigEnabled
@ConditionalOnSpringCloudBootstrapDisabled
@ConditionalOnClass(value = {com.alibaba.csp.sentinel.Env.class, com.alibaba.csp.sentinel.datasource.ReadableDataSource.class, com.alibaba.csp.sentinel.datasource.nacos.NacosDataSource.class, org.zodiac.sentinel.base.model.SentinelRule.class, org.zodiac.sentinel.nacos.config.NacosDataSourceListInfo.class})
public class SentinelNacosDataSourceAutoConfiguration {
public SentinelNacosDataSourceAutoConfiguration() {
super();
}
@Bean
@ConditionalOnMissingBean
@ConfigurationProperties(prefix = org.zodiac.sentinel.nacos.constants.SentinelNacosSystemPropertiesConstants.Zodiac.SENTINEL_DATASOURCE_NACOS_PREFIX)
protected NacosDataSourceListProperties nacosDataSourceListProperties() {
return new NacosDataSourceListProperties();
}
@Bean
@ConditionalOnMissingBean
protected org.zodiac.sentinel.nacos.config.configurer.SentinelNacosDataSourceConfigurer sentinelNacosDataSourceConfigurer(
NacosDataSourceListProperties dataSourceListProperties) {
return new org.zodiac.sentinel.nacos.config.configurer.SentinelNacosDataSourceConfigurer()
.setId(dataSourceListProperties.getId())
.setList(dataSourceListProperties.getList())
.setOrder(dataSourceListProperties.getOrder());
}
}