From 975003fa9b4027a16cd43679de16a065f211f0c5 Mon Sep 17 00:00:00 2001 From: qingliu Date: Thu, 14 Sep 2023 20:21:02 +0800 Subject: [PATCH] fix: move the RemoteConfigFileRepo destroy hook to the Polaris config module. (#1111) --- .../polaris/config/PolarisConfigAutoConfiguration.java | 7 +++++++ .../listener/PolarisConfigApplicationEventListener.java | 6 +++--- .../context/config/PolarisContextAutoConfiguration.java | 6 ------ 3 files changed, 10 insertions(+), 9 deletions(-) rename spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/listener/PolarisContextApplicationEventListener.java => spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/listener/PolarisConfigApplicationEventListener.java (88%) diff --git a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/PolarisConfigAutoConfiguration.java b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/PolarisConfigAutoConfiguration.java index b0c212a14..779e29751 100644 --- a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/PolarisConfigAutoConfiguration.java +++ b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/PolarisConfigAutoConfiguration.java @@ -27,12 +27,14 @@ import com.tencent.cloud.polaris.config.adapter.PolarisRefreshEntireContextRefre import com.tencent.cloud.polaris.config.annotation.PolarisConfigAnnotationProcessor; import com.tencent.cloud.polaris.config.condition.ConditionalOnReflectRefreshType; import com.tencent.cloud.polaris.config.config.PolarisConfigProperties; +import com.tencent.cloud.polaris.config.listener.PolarisConfigApplicationEventListener; import com.tencent.cloud.polaris.config.listener.PolarisConfigChangeEventListener; import com.tencent.cloud.polaris.config.listener.PolarisConfigRefreshOptimizationListener; import com.tencent.cloud.polaris.config.logger.PolarisConfigLoggerApplicationListener; import com.tencent.cloud.polaris.config.spring.annotation.SpringValueProcessor; import com.tencent.cloud.polaris.config.spring.property.PlaceholderHelper; import com.tencent.cloud.polaris.config.spring.property.SpringValueRegistry; +import com.tencent.cloud.polaris.context.PolarisSDKContextManager; import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -120,5 +122,10 @@ public class PolarisConfigAutoConfiguration { public PolarisConfigRefreshOptimizationListener polarisConfigRefreshOptimizationListener() { return new PolarisConfigRefreshOptimizationListener(); } + + @Bean + public PolarisConfigApplicationEventListener polarisContextApplicationEventListener(PolarisSDKContextManager polarisSDKContextManager) { + return new PolarisConfigApplicationEventListener(polarisSDKContextManager); + } } } diff --git a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/listener/PolarisContextApplicationEventListener.java b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/listener/PolarisConfigApplicationEventListener.java similarity index 88% rename from spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/listener/PolarisContextApplicationEventListener.java rename to spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/listener/PolarisConfigApplicationEventListener.java index 0006f71b9..68106382c 100644 --- a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/listener/PolarisContextApplicationEventListener.java +++ b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/listener/PolarisConfigApplicationEventListener.java @@ -16,7 +16,7 @@ * */ -package com.tencent.cloud.polaris.context.listener; +package com.tencent.cloud.polaris.config.listener; import com.tencent.cloud.polaris.context.PolarisSDKContextManager; import com.tencent.polaris.configuration.client.internal.RemoteConfigFileRepo; @@ -33,11 +33,11 @@ import org.springframework.lang.NonNull; * @author shuiqingliu * @since 2023/8/29 **/ -public class PolarisContextApplicationEventListener implements ApplicationListener { +public class PolarisConfigApplicationEventListener implements ApplicationListener { private final PolarisSDKContextManager polarisSDKContextManager; - public PolarisContextApplicationEventListener(PolarisSDKContextManager polarisSDKContextManager) { + public PolarisConfigApplicationEventListener(PolarisSDKContextManager polarisSDKContextManager) { this.polarisSDKContextManager = polarisSDKContextManager; } diff --git a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/config/PolarisContextAutoConfiguration.java b/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/config/PolarisContextAutoConfiguration.java index febf139fd..1593fdd5f 100644 --- a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/config/PolarisContextAutoConfiguration.java +++ b/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/config/PolarisContextAutoConfiguration.java @@ -25,7 +25,6 @@ import com.tencent.cloud.polaris.context.ModifyAddress; import com.tencent.cloud.polaris.context.PolarisConfigModifier; import com.tencent.cloud.polaris.context.PolarisSDKContextManager; import com.tencent.cloud.polaris.context.ServiceRuleManager; -import com.tencent.cloud.polaris.context.listener.PolarisContextApplicationEventListener; import com.tencent.polaris.api.exception.PolarisException; import com.tencent.polaris.client.api.SDKContext; @@ -59,9 +58,4 @@ public class PolarisContextAutoConfiguration { public ServiceRuleManager serviceRuleManager(PolarisSDKContextManager polarisSDKContextManager) { return new ServiceRuleManager(polarisSDKContextManager.getSDKContext(), polarisSDKContextManager.getConsumerAPI()); } - - @Bean - public PolarisContextApplicationEventListener polarisContextApplicationEventListener(PolarisSDKContextManager polarisSDKContextManager) { - return new PolarisContextApplicationEventListener(polarisSDKContextManager); - } }