Skip to content

Commit

Permalink
add autoConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
weihubeats committed Feb 28, 2022
1 parent 5e00d45 commit cd40265
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import cn.hippo4j.core.config.UtilAutoConfiguration;
import cn.hippo4j.core.executor.ThreadPoolNotifyAlarmHandler;
import cn.hippo4j.core.starter.notify.CoreNotifyConfigBuilder;
import cn.hippo4j.core.starter.refresher.ApolloRefresherHandler;
import cn.hippo4j.core.starter.refresher.ConfigParserHandler;
import cn.hippo4j.core.starter.refresher.NacosCloudRefresherHandler;
import cn.hippo4j.core.starter.refresher.NacosRefresherHandler;
Expand All @@ -21,6 +22,7 @@
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
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.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
Expand All @@ -46,6 +48,8 @@ public class DynamicThreadPoolCoreAutoConfiguration {

private static final String NACOS_CONFIG_KEY = "com.alibaba.nacos.api.config";

private static final String APOLLO_CONFIG_KEY = "com.ctrip.framework.apollo.ConfigService.class";

@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ApplicationContextHolder hippo4JApplicationContextHolder() {
Expand Down Expand Up @@ -112,6 +116,15 @@ public NacosCloudRefresherHandler nacosCloudRefresherHandler(NacosConfigManager
return new NacosCloudRefresherHandler(nacosConfigManager, threadPoolNotifyAlarmHandler, configParserHandler, bootstrapCoreProperties);
}

@Bean
@ConditionalOnMissingBean
@ConditionalOnClass(name = APOLLO_CONFIG_KEY)
public ApolloRefresherHandler apolloRefresher(ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler,
ConfigParserHandler configParserHandler,
BootstrapCoreProperties bootstrapCoreProperties) {
return new ApolloRefresherHandler(threadPoolNotifyAlarmHandler, configParserHandler, bootstrapCoreProperties);
}

@Bean
public ConfigParserHandler configParserHandler() {
return new ConfigParserHandler();
Expand Down

0 comments on commit cd40265

Please sign in to comment.