@Test public void testApolloLoad() { ConfigScan.scan(); ServerConfigLoader loader = new ServerConfigLoader(); ApolloConfigLoader apolloConfigLoader = new ApolloConfigLoader(client); loader.load(ConfigLoader.Context::new, (context, config) -> { if (config != null) { if (StringUtils.isNoneBlank(config.getConfigMode())) { String configMode = config.getConfigMode(); if (configMode.equals("apollo")) { apolloConfigLoader.load(context, this::assertTest); } } } }); }
private void apolloLoad(final Supplier<Context> context, final LoaderHandler<ApolloConfig> handler, final ApolloConfig config) { if (config != null) { check(config); LOGGER.info("loader apollo config: {}", config); String fileExtension = config.getFileExtension(); PropertyLoader propertyLoader = LOADERS.get(fileExtension); if (propertyLoader == null) { throw new ConfigException("apollo.fileExtension setting error, The loader was not found"); } InputStream pull = client.pull(config); Optional.ofNullable(pull) .map(e -> propertyLoader.load("remote.apollo." + fileExtension, e)) .ifPresent(e -> context.get().getOriginal().load(() -> context.get().withSources(e), this::apolloFinish)); handler.finish(context, config); passive(context, null, config); } else { throw new ConfigException("apollo config is null"); } }
ApolloConfigLoader implements ConfigLoader<ApolloConfig> { private void apolloLoad(final Supplier<Context> context, final LoaderHandler<ApolloConfig> handler, final ApolloConfig config) { if (config != null) { check(config); LOGGER.info("loader apollo config: {}", config); String fileExtension = config.getFileExtension(); PropertyLoader propertyLoader = LOADERS.get(fileExtension); if (propertyLoader == null) { throw new ConfigException("apollo.fileExtension setting error, The loader was not found"); } InputStream pull = client.pull(config); Optional.ofNullable(pull) .map(e -> propertyLoader.load("remote.apollo." + fileExtension, e)) .ifPresent(e -> context.get().getOriginal().load(() -> context.get().withSources(e), this::apolloFinish)); handler.finish(context, config); passive(context, null, config); } else { throw new ConfigException("apollo config is null"); } } }
ApolloConfigLoader implements ConfigLoader<ApolloConfig> { private void apolloLoad(final Supplier<Context> context, final LoaderHandler<ApolloConfig> handler, final ApolloConfig config) { if (config != null) { check(config); LOGGER.info("loader apollo config: {}", config); String fileExtension = config.getFileExtension(); PropertyLoader propertyLoader = LOADERS.get(fileExtension); if (propertyLoader == null) { throw new ConfigException("apollo.fileExtension setting error, The loader was not found"); } InputStream pull = client.pull(config); Optional.ofNullable(pull) .map(e -> propertyLoader.load("remote.apollo." + fileExtension, e)) .ifPresent(e -> context.get().getOriginal().load(() -> context.get().withSources(e), this::apolloFinish)); handler.finish(context, config); passive(context, null, config); } else { throw new ConfigException("apollo config is null"); } } ApolloConfigLoader();  ApolloConfigLoader(final ApolloClient apolloClient); }
ApolloConfigLoader implements ConfigLoader<ApolloConfig> { private void apolloLoad(final Supplier<Context> context, final LoaderHandler<ApolloConfig> handler, final ApolloConfig config) { if (config != null) { check(config); LOGGER.info("loader apollo config: {}", config); String fileExtension = config.getFileExtension(); PropertyLoader propertyLoader = LOADERS.get(fileExtension); if (propertyLoader == null) { throw new ConfigException("apollo.fileExtension setting error, The loader was not found"); } InputStream pull = client.pull(config); Optional.ofNullable(pull) .map(e -> propertyLoader.load("remote.apollo." + fileExtension, e)) .ifPresent(e -> context.get().getOriginal().load(() -> context.get().withSources(e), this::apolloFinish)); handler.finish(context, config); passive(context, null, config); } else { throw new ConfigException("apollo config is null"); } } ApolloConfigLoader();  ApolloConfigLoader(final ApolloClient apolloClient); @Override void load(final Supplier<Context> context, final LoaderHandler<ApolloConfig> handler); @Override void passive(final Supplier<Context> context, final PassiveHandler<Config> handler, final Config config); }
ApolloConfigLoader implements ConfigLoader<ApolloConfig> { private void apolloLoad(final Supplier<Context> context, final LoaderHandler<ApolloConfig> handler, final ApolloConfig config) { if (config != null) { check(config); LOGGER.info("loader apollo config: {}", config); String fileExtension = config.getFileExtension(); PropertyLoader propertyLoader = LOADERS.get(fileExtension); if (propertyLoader == null) { throw new ConfigException("apollo.fileExtension setting error, The loader was not found"); } InputStream pull = client.pull(config); Optional.ofNullable(pull) .map(e -> propertyLoader.load("remote.apollo." + fileExtension, e)) .ifPresent(e -> context.get().getOriginal().load(() -> context.get().withSources(e), this::apolloFinish)); handler.finish(context, config); passive(context, null, config); } else { throw new ConfigException("apollo config is null"); } } ApolloConfigLoader();  ApolloConfigLoader(final ApolloClient apolloClient); @Override void load(final Supplier<Context> context, final LoaderHandler<ApolloConfig> handler); @Override void passive(final Supplier<Context> context, final PassiveHandler<Config> handler, final Config config);  }