Nacos Parameter init listener by conditional on class
@@ -3,27 +3,33 @@ package org.springframework.cloud.alicloud.context.nacos;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
-import org.springframework.context.ApplicationListener;
+import org.springframework.cloud.alicloud.context.listener.AbstractOnceApplicationListener;
import com.alibaba.cloud.context.edas.EdasChangeOrderConfiguration;
import com.alibaba.cloud.context.edas.EdasChangeOrderConfigurationFactory;
public class NacosParameterInitListener
- implements ApplicationListener<ApplicationEnvironmentPreparedEvent> {
+ extends AbstractOnceApplicationListener<ApplicationEnvironmentPreparedEvent> {
private static final Logger log = LoggerFactory
.getLogger(NacosParameterInitListener.class);
@Override
- public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
+ protected String conditionalOnClass() {
+ return "org.springframework.cloud.alibaba.nacos.NacosConfigAutoConfiguration";
+ }
+ @Override
+ protected void handleEvent(ApplicationEnvironmentPreparedEvent event) {
preparedNacosConfiguration();
}
private void preparedNacosConfiguration() {
EdasChangeOrderConfiguration edasChangeOrderConfiguration = EdasChangeOrderConfigurationFactory
.getEdasChangeOrderConfiguration();
+
log.info("Initialize Nacos Parameter from edas change order,is edas managed {}.",
edasChangeOrderConfiguration.isEdasManaged());
+
if (!edasChangeOrderConfiguration.isEdasManaged()) {
return;
}
