Commit 16bdbe7f by Nepxion

把订阅配置的初始化权限开放出去

parent 8a88f322
...@@ -11,6 +11,8 @@ package com.nepxion.discovery.plugin.configcenter.extension.nacos.adapter; ...@@ -11,6 +11,8 @@ package com.nepxion.discovery.plugin.configcenter.extension.nacos.adapter;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import javax.annotation.PostConstruct;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -51,14 +53,15 @@ public class NacosConfigAdapter extends ConfigAdapter { ...@@ -51,14 +53,15 @@ public class NacosConfigAdapter extends ConfigAdapter {
return configService.getConfig(serviceId, group, timeout); return configService.getConfig(serviceId, group, timeout);
} }
@Override @PostConstruct
public void subscribeConfig() throws Exception { public void subscribeConfig() {
String groupKey = pluginContextAware.getGroupKey(); String groupKey = pluginContextAware.getGroupKey();
String group = pluginAdapter.getGroup(); String group = pluginAdapter.getGroup();
String serviceId = pluginAdapter.getServiceId(); String serviceId = pluginAdapter.getServiceId();
LOG.info("Subscribe remote config from Nacos server, {}={}, serviceId={}", groupKey, group, serviceId); LOG.info("Subscribe remote config from Nacos server, {}={}, serviceId={}", groupKey, group, serviceId);
try {
configService.addListener(serviceId, group, new Listener() { configService.addListener(serviceId, group, new Listener() {
@Override @Override
public void receiveConfigInfo(String config) { public void receiveConfigInfo(String config) {
...@@ -84,5 +87,8 @@ public class NacosConfigAdapter extends ConfigAdapter { ...@@ -84,5 +87,8 @@ public class NacosConfigAdapter extends ConfigAdapter {
return null; return null;
} }
}); });
} catch (Exception e) {
LOG.error("Subscribe config failed", e);
}
} }
} }
\ No newline at end of file
...@@ -9,22 +9,6 @@ package com.nepxion.discovery.plugin.configcenter.loader; ...@@ -9,22 +9,6 @@ package com.nepxion.discovery.plugin.configcenter.loader;
* @version 1.0 * @version 1.0
*/ */
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class RemoteConfigLoader implements ConfigLoader { public abstract class RemoteConfigLoader implements ConfigLoader {
private static final Logger LOG = LoggerFactory.getLogger(RemoteConfigLoader.class);
@PostConstruct
public void initialize() {
try {
subscribeConfig();
} catch (Exception e) {
LOG.error("Subscribe config failed", e);
}
}
protected abstract void subscribeConfig() throws Exception;
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment