|
|
@ -12,18 +12,17 @@ import cn.hippo4j.common.notify.platform.WeChatSendMessageHandler;
|
|
|
|
import cn.hippo4j.core.config.UtilAutoConfiguration;
|
|
|
|
import cn.hippo4j.core.config.UtilAutoConfiguration;
|
|
|
|
import cn.hippo4j.core.executor.ThreadPoolNotifyAlarmHandler;
|
|
|
|
import cn.hippo4j.core.executor.ThreadPoolNotifyAlarmHandler;
|
|
|
|
import cn.hippo4j.core.starter.notify.CoreNotifyConfigBuilder;
|
|
|
|
import cn.hippo4j.core.starter.notify.CoreNotifyConfigBuilder;
|
|
|
|
|
|
|
|
import cn.hippo4j.core.starter.parser.ConfigParserHandler;
|
|
|
|
|
|
|
|
import cn.hippo4j.core.starter.refresher.ApolloRefresherHandler;
|
|
|
|
import cn.hippo4j.core.starter.refresher.NacosCloudRefresherHandler;
|
|
|
|
import cn.hippo4j.core.starter.refresher.NacosCloudRefresherHandler;
|
|
|
|
import cn.hippo4j.core.starter.refresher.NacosRefresherHandler;
|
|
|
|
import cn.hippo4j.core.starter.refresher.NacosRefresherHandler;
|
|
|
|
import cn.hippo4j.core.starter.refresher.config.ConfigParser;
|
|
|
|
|
|
|
|
import cn.hippo4j.core.starter.refresher.config.impl.PropConfigParser;
|
|
|
|
|
|
|
|
import cn.hippo4j.core.starter.refresher.config.impl.YmlConfigParser;
|
|
|
|
|
|
|
|
import cn.hippo4j.core.starter.support.DynamicThreadPoolPostProcessor;
|
|
|
|
import cn.hippo4j.core.starter.support.DynamicThreadPoolPostProcessor;
|
|
|
|
import com.alibaba.cloud.nacos.NacosConfigManager;
|
|
|
|
import com.alibaba.cloud.nacos.NacosConfigManager;
|
|
|
|
import com.alibaba.nacos.api.config.ConfigService;
|
|
|
|
import com.alibaba.nacos.api.config.ConfigService;
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
|
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
@ -31,8 +30,6 @@ import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.core.Ordered;
|
|
|
|
import org.springframework.core.Ordered;
|
|
|
|
import org.springframework.core.annotation.Order;
|
|
|
|
import org.springframework.core.annotation.Order;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Dynamic thread pool auto configuration.
|
|
|
|
* Dynamic thread pool auto configuration.
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -51,8 +48,7 @@ public class DynamicThreadPoolCoreAutoConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
private static final String NACOS_CONFIG_KEY = "com.alibaba.nacos.api.config";
|
|
|
|
private static final String NACOS_CONFIG_KEY = "com.alibaba.nacos.api.config";
|
|
|
|
|
|
|
|
|
|
|
|
private final List<String> yamlList = Lists.newArrayList("yaml", "yml");
|
|
|
|
private static final String APOLLO_CONFIG_KEY = "com.ctrip.framework.apollo.ConfigService.class";
|
|
|
|
private final List<String> propList = Lists.newArrayList("properties");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
@Bean
|
|
|
|
@Order(Ordered.HIGHEST_PRECEDENCE)
|
|
|
|
@Order(Ordered.HIGHEST_PRECEDENCE)
|
|
|
@ -106,32 +102,25 @@ public class DynamicThreadPoolCoreAutoConfiguration {
|
|
|
|
@ConditionalOnMissingClass(NACOS_CONFIG_MANAGER_KEY)
|
|
|
|
@ConditionalOnMissingClass(NACOS_CONFIG_MANAGER_KEY)
|
|
|
|
public NacosRefresherHandler nacosRefresherHandler(ConfigService configService,
|
|
|
|
public NacosRefresherHandler nacosRefresherHandler(ConfigService configService,
|
|
|
|
ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler,
|
|
|
|
ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler,
|
|
|
|
ConfigParser configParser,
|
|
|
|
|
|
|
|
BootstrapCoreProperties bootstrapCoreProperties) {
|
|
|
|
BootstrapCoreProperties bootstrapCoreProperties) {
|
|
|
|
return new NacosRefresherHandler(configService, threadPoolNotifyAlarmHandler, configParser, bootstrapCoreProperties);
|
|
|
|
return new NacosRefresherHandler(configService, threadPoolNotifyAlarmHandler, bootstrapCoreProperties);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
@Bean
|
|
|
|
@ConditionalOnClass(name = NACOS_CONFIG_MANAGER_KEY)
|
|
|
|
@ConditionalOnClass(name = NACOS_CONFIG_MANAGER_KEY)
|
|
|
|
public NacosCloudRefresherHandler nacosCloudRefresherHandler(NacosConfigManager nacosConfigManager,
|
|
|
|
public NacosCloudRefresherHandler nacosCloudRefresherHandler(NacosConfigManager nacosConfigManager,
|
|
|
|
ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler,
|
|
|
|
ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler,
|
|
|
|
ConfigParser configParser,
|
|
|
|
|
|
|
|
BootstrapCoreProperties bootstrapCoreProperties) {
|
|
|
|
BootstrapCoreProperties bootstrapCoreProperties) {
|
|
|
|
return new NacosCloudRefresherHandler(nacosConfigManager, threadPoolNotifyAlarmHandler, configParser, bootstrapCoreProperties);
|
|
|
|
return new NacosCloudRefresherHandler(nacosConfigManager, threadPoolNotifyAlarmHandler, bootstrapCoreProperties);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
@Bean
|
|
|
|
public ConfigParser configParserHandler() {
|
|
|
|
@ConditionalOnMissingBean
|
|
|
|
// return new ConfigParserHandler();
|
|
|
|
@ConditionalOnClass(name = APOLLO_CONFIG_KEY)
|
|
|
|
String configFileType = bootstrapCoreProperties.getConfigFileType();
|
|
|
|
public ApolloRefresherHandler apolloRefresher(ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler,
|
|
|
|
if (yamlList.contains(configFileType)) {
|
|
|
|
BootstrapCoreProperties bootstrapCoreProperties) {
|
|
|
|
return new YmlConfigParser();
|
|
|
|
return new ApolloRefresherHandler(threadPoolNotifyAlarmHandler, bootstrapCoreProperties);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (propList.contains(configFileType)) {
|
|
|
|
|
|
|
|
return new PropConfigParser();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw new UnsupportedOperationException("暂不支持的配置文件类型: " + configFileType);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|