public SimpleApolloConfigDemo() { ConfigChangeListener changeListener = new ConfigChangeListener() { @Override public void onChange(ConfigChangeEvent changeEvent) { logger.info("Changes for namespace {}", changeEvent.getNamespace()); for (String key : changeEvent.changedKeys()) { ConfigChange change = changeEvent.getChange(key); logger.info("Change - key: {}, oldValue: {}, newValue: {}, changeType: {}", change.getPropertyName(), change.getOldValue(), change.getNewValue(), change.getChangeType()); } } }; config = ConfigService.getAppConfig(); config.addChangeListener(changeListener); }
/** * This method will be used to: * 1. get configuration file at startup phase * 2. get all kinds of Dubbo rules */ @Override public String getConfig(String key, String group, long timeout) throws IllegalStateException { if (StringUtils.isNotEmpty(group) && !url.getParameter(Constants.CONFIG_GROUP_KEY, DEFAULT_GROUP).equals(group)) { Config config = ConfigService.getAppConfig(); return config.getProperty(key, null); } return dubboConfig.getProperty(key, null); }
/** * This method will be used to: * 1. get configuration file at startup phase * 2. get all kinds of Dubbo rules */ @Override public String getConfig(String key, String group, long timeout) throws IllegalStateException { if (StringUtils.isNotEmpty(group) && !url.getParameter(Constants.CONFIG_GROUP_KEY, DEFAULT_GROUP).equals(group)) { Config config = ConfigService.getAppConfig(); return config.getProperty(key, null); } return dubboConfig.getProperty(key, null); }
public ApolloConfigDemo() { ConfigChangeListener changeListener = new ConfigChangeListener() { @Override public void onChange(ConfigChangeEvent changeEvent) { logger.info("Changes for namespace {}", changeEvent.getNamespace()); for (String key : changeEvent.changedKeys()) { ConfigChange change = changeEvent.getChange(key); logger.info("Change - key: {}, oldValue: {}, newValue: {}, changeType: {}", change.getPropertyName(), change.getOldValue(), change.getNewValue(), change.getChangeType()); } } }; config = ConfigService.getAppConfig(); config.addChangeListener(changeListener); publicConfig = ConfigService.getConfig("TEST1.apollo"); publicConfig.addChangeListener(changeListener); applicationConfigFile = ConfigService.getConfigFile("application", ConfigFileFormat.Properties); xmlConfigFile = ConfigService.getConfigFile("datasources", ConfigFileFormat.XML); xmlConfigFile.addChangeListener(new ConfigFileChangeListener() { @Override public void onChange(ConfigFileChangeEvent changeEvent) { logger.info(changeEvent.toString()); } }); }
@Bean @ConditionalOnMissingBean public Config apolloConfig() { String namespace = environment.getProperty(ApolloConstant.APOLLO_PLUGIN_NAMESPACE); if (StringUtils.isNotEmpty(namespace)) { return ConfigService.getConfig(namespace); } else { return ConfigService.getAppConfig(); } }
public ApolloConfigLoader(String appId, String metaDomain) { this.config = ConfigService.getAppConfig(); }
@Bean @ConditionalOnMissingBean public Config apolloConfig() { String namespace = environment.getProperty(ApolloConstant.APOLLO_PLUGIN_NAMESPACE); if (StringUtils.isNotEmpty(namespace)) { return ConfigService.getConfig(namespace); } else { return ConfigService.getAppConfig(); } }
public void start() throws Exception { Config config = ConfigService.getAppConfig(); appContext.getBeans(ConfigChangeListener.class).forEach((listener) -> config.addChangeListener(listener)); }
/** * This method will be used to: * 1. get configuration file at startup phase * 2. get all kinds of Dubbo rules */ @Override public String getConfig(String key, String group, long timeout) throws IllegalStateException { if (StringUtils.isNotEmpty(group) && !url.getParameter(Constants.CONFIG_GROUP_KEY, DEFAULT_GROUP).equals(group)) { Config config = ConfigService.getAppConfig(); return config.getProperty(key, null); } return dubboConfig.getProperty(key, null); }
public void init() throws Exception { Config config = ConfigService.getAppConfig(); conf = new PropertiesProxy(); config.getPropertyNames().forEach((key) -> conf.put(key, config.getProperty(key, null))); }
/** * This method will be used to: * 1. get configuration file at startup phase * 2. get all kinds of Dubbo rules */ @Override public String getConfig(String key, String group, long timeout) throws IllegalStateException { if (StringUtils.isNotEmpty(group) && !url.getParameter(Constants.CONFIG_GROUP_KEY, DEFAULT_GROUP).equals(group)) { Config config = ConfigService.getAppConfig(); return config.getProperty(key, null); } return dubboConfig.getProperty(key, null); }