@Test public void testNacosLoad() { ConfigScan.scan(); ServerConfigLoader loader = new ServerConfigLoader(); NacosConfigLoader nacosConfigLoader = new NacosConfigLoader(client); loader.load(ConfigLoader.Context::new, (context, config) -> { if (config != null) { if (StringUtils.isNoneBlank(config.getConfigMode())) { String configMode = config.getConfigMode(); if (configMode.equals("nacos")) { nacosConfigLoader.load(context, this::assertTest); } } } }); }
private void nacosLoad(final Supplier<Context> context, final LoaderHandler<NacosConfig> handler, final NacosConfig config) { if (config != null) { check(config); LOGGER.info("loader nacos config: {}", config); String fileExtension = config.getFileExtension(); PropertyLoader propertyLoader = LOADERS.get(fileExtension); if (propertyLoader == null) { throw new ConfigException("nacos.fileExtension setting error, The loader was not found"); } InputStream pull = client.pull(config); Optional.ofNullable(pull) .map(e -> propertyLoader.load(config.fileName(), e)) .ifPresent(e -> context.get().getOriginal().load(() -> context.get().withSources(e), this::nacosFinish)); handler.finish(context, config); try { client.addListener(context, (c1, c2) -> this.passive(c1, null, c2), config); } catch (NacosException e) { LOGGER.error("passive nacos remote started error...."); } } else { throw new ConfigException("nacos config is null"); } }
NacosConfigLoader implements ConfigLoader<NacosConfig> { private void nacosLoad(final Supplier<Context> context, final LoaderHandler<NacosConfig> handler, final NacosConfig config) { if (config != null) { check(config); LOGGER.info("loader nacos config: {}", config); String fileExtension = config.getFileExtension(); PropertyLoader propertyLoader = LOADERS.get(fileExtension); if (propertyLoader == null) { throw new ConfigException("nacos.fileExtension setting error, The loader was not found"); } InputStream pull = client.pull(config); Optional.ofNullable(pull) .map(e -> propertyLoader.load(config.fileName(), e)) .ifPresent(e -> context.get().getOriginal().load(() -> context.get().withSources(e), this::nacosFinish)); handler.finish(context, config); try { client.addListener(context, (c1, c2) -> this.passive(c1, null, c2), config); } catch (NacosException e) { LOGGER.error("passive nacos remote started error...."); } } else { throw new ConfigException("nacos config is null"); } } }
NacosConfigLoader implements ConfigLoader<NacosConfig> { private void nacosLoad(final Supplier<Context> context, final LoaderHandler<NacosConfig> handler, final NacosConfig config) { if (config != null) { check(config); LOGGER.info("loader nacos config: {}", config); String fileExtension = config.getFileExtension(); PropertyLoader propertyLoader = LOADERS.get(fileExtension); if (propertyLoader == null) { throw new ConfigException("nacos.fileExtension setting error, The loader was not found"); } InputStream pull = client.pull(config); Optional.ofNullable(pull) .map(e -> propertyLoader.load(config.fileName(), e)) .ifPresent(e -> context.get().getOriginal().load(() -> context.get().withSources(e), this::nacosFinish)); handler.finish(context, config); try { client.addListener(context, (c1, c2) -> this.passive(c1, null, c2), config); } catch (NacosException e) { LOGGER.error("passive nacos remote started error...."); } } else { throw new ConfigException("nacos config is null"); } } NacosConfigLoader();  NacosConfigLoader(final NacosClient client); }
NacosConfigLoader implements ConfigLoader<NacosConfig> { private void nacosLoad(final Supplier<Context> context, final LoaderHandler<NacosConfig> handler, final NacosConfig config) { if (config != null) { check(config); LOGGER.info("loader nacos config: {}", config); String fileExtension = config.getFileExtension(); PropertyLoader propertyLoader = LOADERS.get(fileExtension); if (propertyLoader == null) { throw new ConfigException("nacos.fileExtension setting error, The loader was not found"); } InputStream pull = client.pull(config); Optional.ofNullable(pull) .map(e -> propertyLoader.load(config.fileName(), e)) .ifPresent(e -> context.get().getOriginal().load(() -> context.get().withSources(e), this::nacosFinish)); handler.finish(context, config); try { client.addListener(context, (c1, c2) -> this.passive(c1, null, c2), config); } catch (NacosException e) { LOGGER.error("passive nacos remote started error...."); } } else { throw new ConfigException("nacos config is null"); } } NacosConfigLoader();  NacosConfigLoader(final NacosClient client); @Override void load(final Supplier<Context> context, final LoaderHandler<NacosConfig> handler); @Override void passive(final Supplier<Context> context, final PassiveHandler<Config> handler, final Config config); }
NacosConfigLoader implements ConfigLoader<NacosConfig> { private void nacosLoad(final Supplier<Context> context, final LoaderHandler<NacosConfig> handler, final NacosConfig config) { if (config != null) { check(config); LOGGER.info("loader nacos config: {}", config); String fileExtension = config.getFileExtension(); PropertyLoader propertyLoader = LOADERS.get(fileExtension); if (propertyLoader == null) { throw new ConfigException("nacos.fileExtension setting error, The loader was not found"); } InputStream pull = client.pull(config); Optional.ofNullable(pull) .map(e -> propertyLoader.load(config.fileName(), e)) .ifPresent(e -> context.get().getOriginal().load(() -> context.get().withSources(e), this::nacosFinish)); handler.finish(context, config); try { client.addListener(context, (c1, c2) -> this.passive(c1, null, c2), config); } catch (NacosException e) { LOGGER.error("passive nacos remote started error...."); } } else { throw new ConfigException("nacos config is null"); } } NacosConfigLoader();  NacosConfigLoader(final NacosClient client); @Override void load(final Supplier<Context> context, final LoaderHandler<NacosConfig> handler); @Override void passive(final Supplier<Context> context, final PassiveHandler<Config> handler, final Config config);  }