Rename getModelEnvironment to modelEnvironment (#12551)
This commit is contained in:
parent
d3be69b349
commit
3160602072
|
|
@ -54,7 +54,7 @@ public class DefaultGovernanceRuleRepositoryImpl implements GovernanceRuleReposi
|
|||
}
|
||||
|
||||
private DynamicConfiguration getDynamicConfiguration() {
|
||||
return moduleModel.getModelEnvironment().getDynamicConfiguration().orElse(null);
|
||||
return moduleModel.modelEnvironment().getDynamicConfiguration().orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class ShortestResponseLoadBalance extends AbstractLoadBalance implements
|
|||
|
||||
@Override
|
||||
public void setApplicationModel(ApplicationModel applicationModel) {
|
||||
slidePeriod = applicationModel.getModelEnvironment().getConfiguration().getInt(Constants.SHORTEST_RESPONSE_SLIDE_PERIOD, 30_000);
|
||||
slidePeriod = applicationModel.modelEnvironment().getConfiguration().getInt(Constants.SHORTEST_RESPONSE_SLIDE_PERIOD, 30_000);
|
||||
executorService = applicationModel.getFrameworkModel().getBeanFactory()
|
||||
.getBean(FrameworkExecutorRepository.class).getSharedExecutor();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public final class ConfigurationUtils {
|
|||
* @return
|
||||
*/
|
||||
public static Configuration getSystemConfiguration(ScopeModel scopeModel) {
|
||||
return getScopeModelOrDefaultApplicationModel(scopeModel).getModelEnvironment().getSystemConfiguration();
|
||||
return getScopeModelOrDefaultApplicationModel(scopeModel).modelEnvironment().getSystemConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -85,7 +85,7 @@ public final class ConfigurationUtils {
|
|||
* @return
|
||||
*/
|
||||
public static Configuration getEnvConfiguration(ScopeModel scopeModel) {
|
||||
return getScopeModelOrDefaultApplicationModel(scopeModel).getModelEnvironment().getEnvironmentConfiguration();
|
||||
return getScopeModelOrDefaultApplicationModel(scopeModel).modelEnvironment().getEnvironmentConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -97,11 +97,11 @@ public final class ConfigurationUtils {
|
|||
*/
|
||||
|
||||
public static Configuration getGlobalConfiguration(ScopeModel scopeModel) {
|
||||
return getScopeModelOrDefaultApplicationModel(scopeModel).getModelEnvironment().getConfiguration();
|
||||
return getScopeModelOrDefaultApplicationModel(scopeModel).modelEnvironment().getConfiguration();
|
||||
}
|
||||
|
||||
public static Configuration getDynamicGlobalConfiguration(ScopeModel scopeModel) {
|
||||
return scopeModel.getModelEnvironment().getDynamicGlobalConfiguration();
|
||||
return scopeModel.modelEnvironment().getDynamicGlobalConfiguration();
|
||||
}
|
||||
|
||||
// FIXME
|
||||
|
|
@ -364,7 +364,7 @@ public final class ConfigurationUtils {
|
|||
*/
|
||||
@Deprecated
|
||||
public static Configuration getSystemConfiguration() {
|
||||
return ApplicationModel.defaultModel().getModelEnvironment().getSystemConfiguration();
|
||||
return ApplicationModel.defaultModel().modelEnvironment().getSystemConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -374,7 +374,7 @@ public final class ConfigurationUtils {
|
|||
*/
|
||||
@Deprecated
|
||||
public static Configuration getEnvConfiguration() {
|
||||
return ApplicationModel.defaultModel().getModelEnvironment().getEnvironmentConfiguration();
|
||||
return ApplicationModel.defaultModel().modelEnvironment().getEnvironmentConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -384,7 +384,7 @@ public final class ConfigurationUtils {
|
|||
*/
|
||||
@Deprecated
|
||||
public static Configuration getGlobalConfiguration() {
|
||||
return ApplicationModel.defaultModel().getModelEnvironment().getConfiguration();
|
||||
return ApplicationModel.defaultModel().modelEnvironment().getConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -394,7 +394,7 @@ public final class ConfigurationUtils {
|
|||
*/
|
||||
@Deprecated
|
||||
public static Configuration getDynamicGlobalConfiguration() {
|
||||
return ApplicationModel.defaultModel().getDefaultModule().getModelEnvironment().getDynamicGlobalConfiguration();
|
||||
return ApplicationModel.defaultModel().getDefaultModule().modelEnvironment().getDynamicGlobalConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class ModuleEnvironment extends Environment implements ModuleExt {
|
|||
public ModuleEnvironment(ModuleModel moduleModel) {
|
||||
super(moduleModel);
|
||||
this.moduleModel = moduleModel;
|
||||
this.applicationDelegate = moduleModel.getApplicationModel().getModelEnvironment();
|
||||
this.applicationDelegate = moduleModel.getApplicationModel().modelEnvironment();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -696,7 +696,7 @@ public abstract class AbstractConfig implements Serializable {
|
|||
}
|
||||
|
||||
protected void refreshWithPrefixes(List<String> prefixes, ConfigMode configMode) {
|
||||
Environment environment = getScopeModel().getModelEnvironment();
|
||||
Environment environment = getScopeModel().modelEnvironment();
|
||||
List<Map<String, String>> configurationMaps = environment.getConfigurationMaps();
|
||||
|
||||
// Search props starts with PREFIX in order
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
}
|
||||
|
||||
protected Environment getEnvironment() {
|
||||
return getScopeModel().getModelEnvironment();
|
||||
return getScopeModel().modelEnvironment();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ public class MethodConfig extends AbstractMethodConfig {
|
|||
private void refreshArgument(ArgumentConfig argument, InmemoryConfiguration subPropsConfiguration) {
|
||||
if (argument.getIndex() != null && argument.getIndex() >= 0) {
|
||||
String prefix = argument.getIndex() + ".";
|
||||
Environment environment = getScopeModel().getModelEnvironment();
|
||||
Environment environment = getScopeModel().modelEnvironment();
|
||||
List<java.lang.reflect.Method> methods = MethodUtils.getMethods(argument.getClass(),
|
||||
method -> method.getDeclaringClass() != Object.class);
|
||||
for (java.lang.reflect.Method method : methods) {
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
|
|||
this.scopeModel = scopeModel;
|
||||
this.applicationModel = ScopeModelUtil.getApplicationModel(scopeModel);
|
||||
this.supportedConfigTypes = supportedConfigTypes;
|
||||
environment = scopeModel.getModelEnvironment();
|
||||
environment = scopeModel.modelEnvironment();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -113,7 +113,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
|
|||
if (!initialized.compareAndSet(false, true)) {
|
||||
return;
|
||||
}
|
||||
CompositeConfiguration configuration = scopeModel.getModelEnvironment().getConfiguration();
|
||||
CompositeConfiguration configuration = scopeModel.modelEnvironment().getConfiguration();
|
||||
|
||||
// dubbo.config.mode
|
||||
String configModeStr = (String) configuration.getProperty(ConfigKeys.DUBBO_CONFIG_MODE);
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ public class ApplicationModel extends ScopeModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Environment getModelEnvironment() {
|
||||
public Environment modelEnvironment() {
|
||||
if (environment == null) {
|
||||
environment = (Environment) this.getExtensionLoader(ApplicationExt.class)
|
||||
.getExtension(Environment.NAME);
|
||||
|
|
@ -390,11 +390,11 @@ public class ApplicationModel extends ScopeModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @deprecated Replace to {@link ScopeModel#getModelEnvironment()}
|
||||
* @deprecated Replace to {@link ScopeModel#modelEnvironment()}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Environment getEnvironment() {
|
||||
return defaultModel().getModelEnvironment();
|
||||
return defaultModel().modelEnvironment();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ public class FrameworkModel extends ScopeModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Environment getModelEnvironment() {
|
||||
public Environment modelEnvironment() {
|
||||
throw new UnsupportedOperationException("Environment is inaccessible for FrameworkModel");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ public class ModuleModel extends ScopeModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ModuleEnvironment getModelEnvironment() {
|
||||
public ModuleEnvironment modelEnvironment() {
|
||||
if (moduleEnvironment == null) {
|
||||
moduleEnvironment = (ModuleEnvironment) this.getExtensionLoader(ModuleExt.class)
|
||||
.getExtension(ModuleEnvironment.NAME);
|
||||
|
|
|
|||
|
|
@ -243,7 +243,28 @@ public abstract class ScopeModel implements ExtensionAccessor {
|
|||
return Collections.unmodifiableSet(classLoaders);
|
||||
}
|
||||
|
||||
public abstract Environment getModelEnvironment();
|
||||
/**
|
||||
* Get current model's environment.
|
||||
* </br>
|
||||
* Note: This method should not start with `get` or it would be invoked due to Spring boot refresh.
|
||||
* @see <a href="https://github.com/apache/dubbo/issues/12542">Configuration refresh issue</a>
|
||||
*/
|
||||
public abstract Environment modelEnvironment();
|
||||
|
||||
/**
|
||||
* Get current model's environment.
|
||||
*
|
||||
* @see <a href="https://github.com/apache/dubbo/issues/12542">Configuration refresh issue</a>
|
||||
* @deprecated use modelEnvironment() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public final Environment getModelEnvironment() {
|
||||
try {
|
||||
return modelEnvironment();
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getInternalId() {
|
||||
return this.internalId;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class ConfigurationUtilsTest {
|
|||
FrameworkModel frameworkModel = new FrameworkModel();
|
||||
|
||||
ApplicationModel applicationModel = frameworkModel.newApplication();
|
||||
Environment originApplicationEnvironment = applicationModel.getModelEnvironment();
|
||||
Environment originApplicationEnvironment = applicationModel.modelEnvironment();
|
||||
Environment applicationEnvironment = Mockito.spy(originApplicationEnvironment);
|
||||
applicationModel.setEnvironment(applicationEnvironment);
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ class ConfigurationUtilsTest {
|
|||
Assertions.assertEquals("a", ConfigurationUtils.getCachedDynamicProperty(applicationModel, "TestKey", "xxx"));
|
||||
|
||||
ModuleModel moduleModel = applicationModel.newModule();
|
||||
ModuleEnvironment originModuleEnvironment = moduleModel.getModelEnvironment();
|
||||
ModuleEnvironment originModuleEnvironment = moduleModel.modelEnvironment();
|
||||
ModuleEnvironment moduleEnvironment = Mockito.spy(originModuleEnvironment);
|
||||
moduleModel.setModuleEnvironment(moduleEnvironment);
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class EnvironmentTest {
|
|||
|
||||
@Test
|
||||
void testResolvePlaceholders() {
|
||||
Environment environment = ApplicationModel.defaultModel().getModelEnvironment();
|
||||
Environment environment = ApplicationModel.defaultModel().modelEnvironment();
|
||||
|
||||
Map<String, String> externalMap = new LinkedHashMap<>();
|
||||
externalMap.put("zookeeper.address", "127.0.0.1");
|
||||
|
|
@ -65,7 +65,7 @@ class EnvironmentTest {
|
|||
void test() {
|
||||
FrameworkModel frameworkModel = new FrameworkModel();
|
||||
ApplicationModel applicationModel = frameworkModel.newApplication();
|
||||
Environment environment = applicationModel.getModelEnvironment();
|
||||
Environment environment = applicationModel.modelEnvironment();
|
||||
|
||||
// test getPrefixedConfiguration
|
||||
RegistryConfig registryConfig = new RegistryConfig();
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class ModuleModelTest {
|
|||
ApplicationModel applicationModel = frameworkModel.newApplication();
|
||||
ModuleModel moduleModel = applicationModel.newModule();
|
||||
|
||||
ModuleEnvironment modelEnvironment = moduleModel.getModelEnvironment();
|
||||
ModuleEnvironment modelEnvironment = moduleModel.modelEnvironment();
|
||||
Assertions.assertNotNull(modelEnvironment);
|
||||
|
||||
frameworkModel.destroy();
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ class ScopeModelUtilTest {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Environment getModelEnvironment() {
|
||||
public Environment modelEnvironment() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ public final class DubboBootstrap {
|
|||
private DubboBootstrap(ApplicationModel applicationModel) {
|
||||
this.applicationModel = applicationModel;
|
||||
configManager = applicationModel.getApplicationConfigManager();
|
||||
environment = applicationModel.getModelEnvironment();
|
||||
environment = applicationModel.modelEnvironment();
|
||||
|
||||
executorRepository = ExecutorRepository.getInstance(applicationModel);
|
||||
applicationDeployer = applicationModel.getDeployer();
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ public class DefaultApplicationDeployer extends AbstractDeployer<ApplicationMode
|
|||
super(applicationModel);
|
||||
this.applicationModel = applicationModel;
|
||||
configManager = applicationModel.getApplicationConfigManager();
|
||||
environment = applicationModel.getModelEnvironment();
|
||||
environment = applicationModel.modelEnvironment();
|
||||
|
||||
referenceCache = new CompositeReferenceCache(applicationModel);
|
||||
frameworkExecutorRepository = applicationModel.getFrameworkModel().getBeanFactory().getBean(FrameworkExecutorRepository.class);
|
||||
|
|
|
|||
|
|
@ -475,7 +475,7 @@ public class ConfigValidationUtils {
|
|||
|
||||
// backward compatibility
|
||||
ScopeModel scopeModel = ScopeModelUtil.getOrDefaultApplicationModel(config.getScopeModel());
|
||||
PropertiesConfiguration configuration = scopeModel.getModelEnvironment().getPropertiesConfiguration();
|
||||
PropertiesConfiguration configuration = scopeModel.modelEnvironment().getPropertiesConfiguration();
|
||||
String wait = configuration.getProperty(SHUTDOWN_WAIT_KEY);
|
||||
if (wait != null && wait.trim().length() > 0) {
|
||||
System.setProperty(SHUTDOWN_WAIT_KEY, wait.trim());
|
||||
|
|
|
|||
|
|
@ -335,8 +335,8 @@ class AbstractConfigTest {
|
|||
external.put("dubbo.override.key", "external");
|
||||
// @Parameter(key="key2", useKeyAsProperty=true)
|
||||
external.put("dubbo.override.key2", "external");
|
||||
ApplicationModel.defaultModel().getModelEnvironment().initialize();
|
||||
ApplicationModel.defaultModel().getModelEnvironment().setExternalConfigMap(external);
|
||||
ApplicationModel.defaultModel().modelEnvironment().initialize();
|
||||
ApplicationModel.defaultModel().modelEnvironment().setExternalConfigMap(external);
|
||||
|
||||
SysProps.setProperty("dubbo.override.address", "system://127.0.0.1:2181");
|
||||
SysProps.setProperty("dubbo.override.protocol", "system");
|
||||
|
|
@ -353,7 +353,7 @@ class AbstractConfigTest {
|
|||
Assertions.assertEquals("external", overrideConfig.getKey());
|
||||
Assertions.assertEquals("system", overrideConfig.getKey2());
|
||||
} finally {
|
||||
ApplicationModel.defaultModel().getModelEnvironment().destroy();
|
||||
ApplicationModel.defaultModel().modelEnvironment().destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -377,14 +377,14 @@ class AbstractConfigTest {
|
|||
Assertions.assertEquals("override-config://", overrideConfig.getEscape());
|
||||
Assertions.assertEquals("system", overrideConfig.getKey());
|
||||
} finally {
|
||||
ApplicationModel.defaultModel().getModelEnvironment().destroy();
|
||||
ApplicationModel.defaultModel().modelEnvironment().destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRefreshProperties() throws Exception {
|
||||
try {
|
||||
ApplicationModel.defaultModel().getModelEnvironment().setExternalConfigMap(new HashMap<>());
|
||||
ApplicationModel.defaultModel().modelEnvironment().setExternalConfigMap(new HashMap<>());
|
||||
OverrideConfig overrideConfig = new OverrideConfig();
|
||||
overrideConfig.setAddress("override-config://127.0.0.1:2181");
|
||||
overrideConfig.setProtocol("override-config");
|
||||
|
|
@ -392,7 +392,7 @@ class AbstractConfigTest {
|
|||
|
||||
Properties properties = new Properties();
|
||||
properties.load(this.getClass().getResourceAsStream("/dubbo.properties"));
|
||||
ApplicationModel.defaultModel().getModelEnvironment().getPropertiesConfiguration().setProperties(properties);
|
||||
ApplicationModel.defaultModel().modelEnvironment().getPropertiesConfiguration().setProperties(properties);
|
||||
|
||||
overrideConfig.refresh();
|
||||
|
||||
|
|
@ -402,7 +402,7 @@ class AbstractConfigTest {
|
|||
Assertions.assertEquals("properties", overrideConfig.getKey2());
|
||||
//Assertions.assertEquals("properties", overrideConfig.getUseKeyAsProperty());
|
||||
} finally {
|
||||
ApplicationModel.defaultModel().getModelEnvironment().destroy();
|
||||
ApplicationModel.defaultModel().modelEnvironment().destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -425,8 +425,8 @@ class AbstractConfigTest {
|
|||
external.put("dubbo.override.key", "external");
|
||||
// @Parameter(key="key2", useKeyAsProperty=true)
|
||||
external.put("dubbo.override.key2", "external");
|
||||
ApplicationModel.defaultModel().getModelEnvironment().initialize();
|
||||
ApplicationModel.defaultModel().getModelEnvironment().setExternalConfigMap(external);
|
||||
ApplicationModel.defaultModel().modelEnvironment().initialize();
|
||||
ApplicationModel.defaultModel().modelEnvironment().setExternalConfigMap(external);
|
||||
|
||||
overrideConfig.refresh();
|
||||
|
||||
|
|
@ -437,7 +437,7 @@ class AbstractConfigTest {
|
|||
Assertions.assertEquals("external", overrideConfig.getKey());
|
||||
Assertions.assertEquals("external", overrideConfig.getKey2());
|
||||
} finally {
|
||||
ApplicationModel.defaultModel().getModelEnvironment().destroy();
|
||||
ApplicationModel.defaultModel().modelEnvironment().destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -457,8 +457,8 @@ class AbstractConfigTest {
|
|||
external.put("dubbo.overrides.override-id.key2", "external");
|
||||
external.put("dubbo.override.address", "external://127.0.0.1:2181");
|
||||
external.put("dubbo.override.exclude", "external");
|
||||
ApplicationModel.defaultModel().getModelEnvironment().initialize();
|
||||
ApplicationModel.defaultModel().getModelEnvironment().setExternalConfigMap(external);
|
||||
ApplicationModel.defaultModel().modelEnvironment().initialize();
|
||||
ApplicationModel.defaultModel().modelEnvironment().setExternalConfigMap(external);
|
||||
|
||||
// refresh config
|
||||
overrideConfig.refresh();
|
||||
|
|
@ -469,7 +469,7 @@ class AbstractConfigTest {
|
|||
Assertions.assertEquals("external", overrideConfig.getKey());
|
||||
Assertions.assertEquals("external", overrideConfig.getKey2());
|
||||
} finally {
|
||||
ApplicationModel.defaultModel().getModelEnvironment().destroy();
|
||||
ApplicationModel.defaultModel().modelEnvironment().destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -485,8 +485,8 @@ class AbstractConfigTest {
|
|||
|
||||
Map<String, String> external = new HashMap<>();
|
||||
external.put("dubbo.override.parameters", "[{key3:value3},{key4:value4},{key2:value5}]");
|
||||
ApplicationModel.defaultModel().getModelEnvironment().initialize();
|
||||
ApplicationModel.defaultModel().getModelEnvironment().setExternalConfigMap(external);
|
||||
ApplicationModel.defaultModel().modelEnvironment().initialize();
|
||||
ApplicationModel.defaultModel().modelEnvironment().setExternalConfigMap(external);
|
||||
|
||||
// refresh config
|
||||
overrideConfig.refresh();
|
||||
|
|
@ -502,7 +502,7 @@ class AbstractConfigTest {
|
|||
Assertions.assertEquals("value6", overrideConfig.getParameters().get("key3"));
|
||||
Assertions.assertEquals("value4", overrideConfig.getParameters().get("key4"));
|
||||
} finally {
|
||||
ApplicationModel.defaultModel().getModelEnvironment().destroy();
|
||||
ApplicationModel.defaultModel().modelEnvironment().destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -514,7 +514,7 @@ class AbstractConfigTest {
|
|||
overrideConfig.refresh();
|
||||
assertEquals("value00", overrideConfig.getParameters().get("key00"));
|
||||
} finally {
|
||||
ApplicationModel.defaultModel().getModelEnvironment().destroy();
|
||||
ApplicationModel.defaultModel().modelEnvironment().destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -587,14 +587,14 @@ class AbstractConfigTest {
|
|||
external.put("notConflictKey", "value-from-external");
|
||||
external.put("dubbo.override.notConflictKey2", "value-from-external");
|
||||
|
||||
ApplicationModel.defaultModel().getModelEnvironment().setExternalConfigMap(external);
|
||||
ApplicationModel.defaultModel().modelEnvironment().setExternalConfigMap(external);
|
||||
|
||||
overrideConfig.refresh();
|
||||
|
||||
Assertions.assertEquals("value-from-config", overrideConfig.getNotConflictKey());
|
||||
Assertions.assertEquals("value-from-external", overrideConfig.getNotConflictKey2());
|
||||
} finally {
|
||||
ApplicationModel.defaultModel().getModelEnvironment().destroy();
|
||||
ApplicationModel.defaultModel().modelEnvironment().destroy();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1021,8 +1021,8 @@ class AbstractConfigTest {
|
|||
external.put("dubbo.outer.a1", "1");
|
||||
external.put("dubbo.outer.b.b1", "11");
|
||||
external.put("dubbo.outer.b.b2", "12");
|
||||
ApplicationModel.defaultModel().getModelEnvironment().initialize();
|
||||
ApplicationModel.defaultModel().getModelEnvironment().setExternalConfigMap(external);
|
||||
ApplicationModel.defaultModel().modelEnvironment().initialize();
|
||||
ApplicationModel.defaultModel().modelEnvironment().setExternalConfigMap(external);
|
||||
|
||||
// refresh config
|
||||
outerConfig.refresh();
|
||||
|
|
@ -1031,7 +1031,7 @@ class AbstractConfigTest {
|
|||
Assertions.assertEquals(11, outerConfig.getB().getB1());
|
||||
Assertions.assertEquals(12, outerConfig.getB().getB2());
|
||||
} finally {
|
||||
ApplicationModel.defaultModel().getModelEnvironment().destroy();
|
||||
ApplicationModel.defaultModel().modelEnvironment().destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -160,8 +160,8 @@ class ConfigCenterConfigTest {
|
|||
|
||||
ApplicationModel.defaultModel().getDefaultModule();
|
||||
// Config instance has id, dubbo props has no id
|
||||
ApplicationModel.defaultModel().getModelEnvironment().getPropertiesConfiguration().setProperty("dubbo.config-center.check", "false");
|
||||
ApplicationModel.defaultModel().getModelEnvironment().getPropertiesConfiguration().setProperty("dubbo.config-center.timeout", "1234");
|
||||
ApplicationModel.defaultModel().modelEnvironment().getPropertiesConfiguration().setProperty("dubbo.config-center.check", "false");
|
||||
ApplicationModel.defaultModel().modelEnvironment().getPropertiesConfiguration().setProperty("dubbo.config-center.timeout", "1234");
|
||||
|
||||
try {
|
||||
// Config instance has id
|
||||
|
|
@ -179,7 +179,7 @@ class ConfigCenterConfigTest {
|
|||
Assertions.assertEquals(3000L, configCenter.getTimeout());
|
||||
Assertions.assertEquals(false, configCenter.isCheck());
|
||||
} finally {
|
||||
ApplicationModel.defaultModel().getModelEnvironment().getPropertiesConfiguration().refresh();
|
||||
ApplicationModel.defaultModel().modelEnvironment().getPropertiesConfiguration().refresh();
|
||||
DubboBootstrap.getInstance().stop();
|
||||
}
|
||||
}
|
||||
|
|
@ -215,8 +215,8 @@ class ConfigCenterConfigTest {
|
|||
|
||||
ApplicationModel.defaultModel().getDefaultModule();
|
||||
// Config instance has id, dubbo props has id
|
||||
ApplicationModel.defaultModel().getModelEnvironment().getPropertiesConfiguration().setProperty("dubbo.config-centers.configcenterA.check", "false");
|
||||
ApplicationModel.defaultModel().getModelEnvironment().getPropertiesConfiguration().setProperty("dubbo.config-centers.configcenterA.timeout", "1234");
|
||||
ApplicationModel.defaultModel().modelEnvironment().getPropertiesConfiguration().setProperty("dubbo.config-centers.configcenterA.check", "false");
|
||||
ApplicationModel.defaultModel().modelEnvironment().getPropertiesConfiguration().setProperty("dubbo.config-centers.configcenterA.timeout", "1234");
|
||||
|
||||
try {
|
||||
// Config instance has id
|
||||
|
|
@ -235,7 +235,7 @@ class ConfigCenterConfigTest {
|
|||
Assertions.assertEquals(3000L, configCenter.getTimeout());
|
||||
Assertions.assertEquals(false, configCenter.isCheck());
|
||||
} finally {
|
||||
ApplicationModel.defaultModel().getModelEnvironment().getPropertiesConfiguration().refresh();
|
||||
ApplicationModel.defaultModel().modelEnvironment().getPropertiesConfiguration().refresh();
|
||||
DubboBootstrap.getInstance().stop();
|
||||
}
|
||||
}
|
||||
|
|
@ -294,4 +294,4 @@ class ConfigCenterConfigTest {
|
|||
Assertions.assertEquals("pass123", cc.getPassword());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -187,9 +187,9 @@ class ConsumerConfigTest {
|
|||
@Test
|
||||
void testOverrideConfigByDubboProps() {
|
||||
ApplicationModel.defaultModel().getDefaultModule();
|
||||
ApplicationModel.defaultModel().getModelEnvironment().getPropertiesConfiguration().setProperty("dubbo.consumers.consumerA.check", "false");
|
||||
ApplicationModel.defaultModel().getModelEnvironment().getPropertiesConfiguration().setProperty("dubbo.consumers.consumerA.group", "demo");
|
||||
ApplicationModel.defaultModel().getModelEnvironment().getPropertiesConfiguration().setProperty("dubbo.consumers.consumerA.threads", "10");
|
||||
ApplicationModel.defaultModel().modelEnvironment().getPropertiesConfiguration().setProperty("dubbo.consumers.consumerA.check", "false");
|
||||
ApplicationModel.defaultModel().modelEnvironment().getPropertiesConfiguration().setProperty("dubbo.consumers.consumerA.group", "demo");
|
||||
ApplicationModel.defaultModel().modelEnvironment().getPropertiesConfiguration().setProperty("dubbo.consumers.consumerA.threads", "10");
|
||||
|
||||
try {
|
||||
ConsumerConfig consumerConfig = new ConsumerConfig();
|
||||
|
|
@ -208,7 +208,7 @@ class ConsumerConfigTest {
|
|||
Assertions.assertEquals("groupA", consumerConfig.getGroup());
|
||||
Assertions.assertEquals(10, consumerConfig.getThreads());
|
||||
} finally {
|
||||
ApplicationModel.defaultModel().getModelEnvironment().getPropertiesConfiguration().refresh();
|
||||
ApplicationModel.defaultModel().modelEnvironment().getPropertiesConfiguration().refresh();
|
||||
DubboBootstrap.getInstance().destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,13 +115,13 @@ class DubboBootstrapTest {
|
|||
System.clearProperty(SHUTDOWN_WAIT_SECONDS_KEY);
|
||||
|
||||
writeDubboProperties(SHUTDOWN_WAIT_KEY, "100");
|
||||
ApplicationModel.defaultModel().getModelEnvironment().getPropertiesConfiguration().refresh();
|
||||
ApplicationModel.defaultModel().modelEnvironment().getPropertiesConfiguration().refresh();
|
||||
ConfigValidationUtils.validateApplicationConfig(new ApplicationConfig("demo"));
|
||||
Assertions.assertEquals("100", System.getProperty(SHUTDOWN_WAIT_KEY));
|
||||
|
||||
System.clearProperty(SHUTDOWN_WAIT_KEY);
|
||||
writeDubboProperties(SHUTDOWN_WAIT_SECONDS_KEY, "1000");
|
||||
ApplicationModel.defaultModel().getModelEnvironment().getPropertiesConfiguration().refresh();
|
||||
ApplicationModel.defaultModel().modelEnvironment().getPropertiesConfiguration().refresh();
|
||||
ConfigValidationUtils.validateApplicationConfig(new ApplicationConfig("demo"));
|
||||
Assertions.assertEquals("1000", System.getProperty(SHUTDOWN_WAIT_SECONDS_KEY));
|
||||
} finally {
|
||||
|
|
@ -369,4 +369,4 @@ class DubboBootstrapTest {
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public class DubboInfraBeanRegisterPostProcessor implements BeanDefinitionRegist
|
|||
// Extract dubbo props from Spring env and put them to app config
|
||||
ConfigurableEnvironment environment = (ConfigurableEnvironment) applicationContext.getEnvironment();
|
||||
SortedMap<String, String> dubboProperties = EnvironmentUtils.filterDubboProperties(environment);
|
||||
applicationModel.getModelEnvironment().setAppConfigMap(dubboProperties);
|
||||
applicationModel.modelEnvironment().setAppConfigMap(dubboProperties);
|
||||
|
||||
// register ConfigManager singleton
|
||||
beanFactory.registerSingleton(ConfigManager.BEAN_NAME, applicationModel.getApplicationConfigManager());
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ public class ServiceDiscoveryRegistryDirectory<T> extends DynamicDirectory<T> {
|
|||
|
||||
@Override
|
||||
public void subscribe(URL url) {
|
||||
if (moduleModel.getModelEnvironment().getConfiguration().convert(Boolean.class, Constants.ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
if (moduleModel.modelEnvironment().getConfiguration().convert(Boolean.class, Constants.ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
enableConfigurationListen = true;
|
||||
getConsumerConfigurationListener(moduleModel).addNotifyListener(this);
|
||||
referenceConfigurationListener = new ReferenceConfigurationListener(this.moduleModel, this, url);
|
||||
|
|
@ -143,7 +143,7 @@ public class ServiceDiscoveryRegistryDirectory<T> extends DynamicDirectory<T> {
|
|||
public void unSubscribe(URL url) {
|
||||
super.unSubscribe(url);
|
||||
this.originalUrls = null;
|
||||
if (moduleModel.getModelEnvironment().getConfiguration().convert(Boolean.class, Constants.ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
if (moduleModel.modelEnvironment().getConfiguration().convert(Boolean.class, Constants.ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
getConsumerConfigurationListener(moduleModel).removeNotifyListener(this);
|
||||
referenceConfigurationListener.stop();
|
||||
}
|
||||
|
|
@ -152,7 +152,7 @@ public class ServiceDiscoveryRegistryDirectory<T> extends DynamicDirectory<T> {
|
|||
@Override
|
||||
public void destroy() {
|
||||
super.destroy();
|
||||
if (moduleModel.getModelEnvironment().getConfiguration().convert(Boolean.class, Constants.ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
if (moduleModel.modelEnvironment().getConfiguration().convert(Boolean.class, Constants.ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
getConsumerConfigurationListener(moduleModel).removeNotifyListener(this);
|
||||
referenceConfigurationListener.stop();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public class MigrationRuleListener implements RegistryProtocolListener, Configur
|
|||
|
||||
private void init() {
|
||||
this.ruleKey = moduleModel.getApplicationModel().getApplicationName() + ".migration";
|
||||
this.configuration = moduleModel.getModelEnvironment().getDynamicConfiguration().orElse(null);
|
||||
this.configuration = moduleModel.modelEnvironment().getDynamicConfiguration().orElse(null);
|
||||
|
||||
if (this.configuration != null) {
|
||||
logger.info("Listening for migration rules on dataId " + ruleKey + ", group " + DUBBO_SERVICEDISCOVERY_MIGRATION);
|
||||
|
|
@ -115,7 +115,7 @@ public class MigrationRuleListener implements RegistryProtocolListener, Configur
|
|||
setRawRule(INIT);
|
||||
}
|
||||
|
||||
String localRawRule = moduleModel.getModelEnvironment().getLocalMigrationRule();
|
||||
String localRawRule = moduleModel.modelEnvironment().getLocalMigrationRule();
|
||||
if (!StringUtils.isEmpty(localRawRule)) {
|
||||
localRuleMigrationFuture = moduleModel.getApplicationModel().getFrameworkModel().getBeanFactory()
|
||||
.getBean(FrameworkExecutorRepository.class).getSharedScheduledExecutor()
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ public class RegistryDirectory<T> extends DynamicDirectory<T> {
|
|||
return null;
|
||||
}
|
||||
);
|
||||
if (moduleModel.getModelEnvironment().getConfiguration().convert(Boolean.class, org.apache.dubbo.registry.Constants.ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
if (moduleModel.modelEnvironment().getConfiguration().convert(Boolean.class, org.apache.dubbo.registry.Constants.ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
consumerConfigurationListener.addNotifyListener(this);
|
||||
referenceConfigurationListener = new ReferenceConfigurationListener(moduleModel, this, url);
|
||||
}
|
||||
|
|
@ -152,7 +152,7 @@ public class RegistryDirectory<T> extends DynamicDirectory<T> {
|
|||
@Override
|
||||
public void unSubscribe(URL url) {
|
||||
super.unSubscribe(url);
|
||||
if (moduleModel.getModelEnvironment().getConfiguration().convert(Boolean.class, org.apache.dubbo.registry.Constants.ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
if (moduleModel.modelEnvironment().getConfiguration().convert(Boolean.class, org.apache.dubbo.registry.Constants.ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
consumerConfigurationListener.removeNotifyListener(this);
|
||||
if (referenceConfigurationListener != null) {
|
||||
referenceConfigurationListener.stop();
|
||||
|
|
@ -163,7 +163,7 @@ public class RegistryDirectory<T> extends DynamicDirectory<T> {
|
|||
@Override
|
||||
public void destroy() {
|
||||
super.destroy();
|
||||
if (moduleModel.getModelEnvironment().getConfiguration().convert(Boolean.class, org.apache.dubbo.registry.Constants.ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
if (moduleModel.modelEnvironment().getConfiguration().convert(Boolean.class, org.apache.dubbo.registry.Constants.ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
consumerConfigurationListener.removeNotifyListener(this);
|
||||
if (referenceConfigurationListener != null) {
|
||||
referenceConfigurationListener.stop();
|
||||
|
|
@ -183,7 +183,7 @@ public class RegistryDirectory<T> extends DynamicDirectory<T> {
|
|||
.filter(this::isNotCompatibleFor26x)
|
||||
.collect(Collectors.groupingBy(this::judgeCategory));
|
||||
|
||||
if (moduleModel.getModelEnvironment().getConfiguration().convert(Boolean.class, ENABLE_26X_CONFIGURATION_LISTEN, true)) {
|
||||
if (moduleModel.modelEnvironment().getConfiguration().convert(Boolean.class, ENABLE_26X_CONFIGURATION_LISTEN, true)) {
|
||||
List<URL> configuratorURLs = categoryUrls.getOrDefault(CONFIGURATORS_CATEGORY, Collections.emptyList());
|
||||
this.configurators = Configurator.toConfigurators(configuratorURLs).orElse(this.configurators);
|
||||
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ public class RegistryProtocol implements Protocol, ScopeModelAware {
|
|||
exporter.setRegistered(register);
|
||||
|
||||
ApplicationModel applicationModel = getApplicationModel(providerUrl.getScopeModel());
|
||||
if (applicationModel.getModelEnvironment().getConfiguration().convert(Boolean.class, ENABLE_26X_CONFIGURATION_LISTEN, true)) {
|
||||
if (applicationModel.modelEnvironment().getConfiguration().convert(Boolean.class, ENABLE_26X_CONFIGURATION_LISTEN, true)) {
|
||||
if (!registry.isServiceDiscovery()) {
|
||||
// Deprecated! Subscribe to override rules in 2.6.x or before.
|
||||
registry.subscribe(overrideSubscribeUrl, overrideSubscribeListener);
|
||||
|
|
@ -657,7 +657,7 @@ public class RegistryProtocol implements Protocol, ScopeModelAware {
|
|||
}
|
||||
|
||||
for (ApplicationModel applicationModel : frameworkModel.getApplicationModels()) {
|
||||
if (applicationModel.getModelEnvironment().getConfiguration().convert(Boolean.class, org.apache.dubbo.registry.Constants.ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
if (applicationModel.modelEnvironment().getConfiguration().convert(Boolean.class, org.apache.dubbo.registry.Constants.ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
for (ModuleModel moduleModel : applicationModel.getPubModuleModels()) {
|
||||
String applicationName = applicationModel.tryGetApplicationName();
|
||||
if (applicationName == null) {
|
||||
|
|
@ -869,7 +869,7 @@ public class RegistryProtocol implements Protocol, ScopeModelAware {
|
|||
this.providerUrl = providerUrl;
|
||||
this.notifyListener = notifyListener;
|
||||
this.moduleModel = moduleModel;
|
||||
if (moduleModel.getModelEnvironment().getConfiguration().convert(Boolean.class, ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
if (moduleModel.modelEnvironment().getConfiguration().convert(Boolean.class, ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
this.initWith(DynamicConfiguration.getRuleKey(providerUrl) + CONFIGURATORS_SUFFIX);
|
||||
}
|
||||
}
|
||||
|
|
@ -899,7 +899,7 @@ public class RegistryProtocol implements Protocol, ScopeModelAware {
|
|||
public ProviderConfigurationListener(ModuleModel moduleModel) {
|
||||
super(moduleModel);
|
||||
this.moduleModel = moduleModel;
|
||||
if (moduleModel.getModelEnvironment().getConfiguration().convert(Boolean.class, ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
if (moduleModel.modelEnvironment().getConfiguration().convert(Boolean.class, ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
this.initWith(moduleModel.getApplicationModel().getApplicationName() + CONFIGURATORS_SUFFIX);
|
||||
}
|
||||
}
|
||||
|
|
@ -1009,12 +1009,12 @@ public class RegistryProtocol implements Protocol, ScopeModelAware {
|
|||
if (listeners != null) {
|
||||
if (listeners.remove(notifyListener)) {
|
||||
ApplicationModel applicationModel = getApplicationModel(registerUrl.getScopeModel());
|
||||
if (applicationModel.getModelEnvironment().getConfiguration().convert(Boolean.class, ENABLE_26X_CONFIGURATION_LISTEN, true)) {
|
||||
if (applicationModel.modelEnvironment().getConfiguration().convert(Boolean.class, ENABLE_26X_CONFIGURATION_LISTEN, true)) {
|
||||
if (!registry.isServiceDiscovery()) {
|
||||
registry.unsubscribe(subscribeUrl, notifyListener);
|
||||
}
|
||||
}
|
||||
if (applicationModel.getModelEnvironment().getConfiguration().convert(Boolean.class, ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
if (applicationModel.modelEnvironment().getConfiguration().convert(Boolean.class, ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
for (ModuleModel moduleModel : applicationModel.getPubModuleModels()) {
|
||||
if (moduleModel.getServiceRepository().getExportedServices().size() > 0) {
|
||||
moduleModel.getExtensionLoader(GovernanceRuleRepository.class).getDefaultExtension()
|
||||
|
|
|
|||
|
|
@ -90,8 +90,8 @@ class MigrationRuleListenerTest {
|
|||
DynamicConfiguration dynamicConfiguration = Mockito.mock(DynamicConfiguration.class);
|
||||
|
||||
ApplicationModel.reset();
|
||||
ApplicationModel.defaultModel().getDefaultModule().getModelEnvironment().setDynamicConfiguration(dynamicConfiguration);
|
||||
ApplicationModel.defaultModel().getDefaultModule().getModelEnvironment().setLocalMigrationRule(localRule);
|
||||
ApplicationModel.defaultModel().getDefaultModule().modelEnvironment().setDynamicConfiguration(dynamicConfiguration);
|
||||
ApplicationModel.defaultModel().getDefaultModule().modelEnvironment().setLocalMigrationRule(localRule);
|
||||
ApplicationConfig applicationConfig = new ApplicationConfig();
|
||||
applicationConfig.setName("demo-consumer");
|
||||
ApplicationModel.defaultModel().getApplicationConfigManager().setApplication(applicationConfig);
|
||||
|
|
@ -134,8 +134,8 @@ class MigrationRuleListenerTest {
|
|||
*/
|
||||
@Test
|
||||
void testWithInitAndNoLocalRule() {
|
||||
ApplicationModel.defaultModel().getDefaultModule().getModelEnvironment().setDynamicConfiguration(null);
|
||||
ApplicationModel.defaultModel().getDefaultModule().getModelEnvironment().setLocalMigrationRule("");
|
||||
ApplicationModel.defaultModel().getDefaultModule().modelEnvironment().setDynamicConfiguration(null);
|
||||
ApplicationModel.defaultModel().getDefaultModule().modelEnvironment().setLocalMigrationRule("");
|
||||
ApplicationConfig applicationConfig = new ApplicationConfig();
|
||||
applicationConfig.setName("demo-consumer");
|
||||
ApplicationModel.defaultModel().getApplicationConfigManager().setApplication(applicationConfig);
|
||||
|
|
@ -170,8 +170,8 @@ class MigrationRuleListenerTest {
|
|||
DynamicConfiguration dynamicConfiguration = Mockito.mock(DynamicConfiguration.class);
|
||||
Mockito.doReturn(remoteRule).when(dynamicConfiguration).getConfig(Mockito.anyString(), Mockito.anyString());
|
||||
|
||||
ApplicationModel.defaultModel().getDefaultModule().getModelEnvironment().setDynamicConfiguration(dynamicConfiguration);
|
||||
ApplicationModel.defaultModel().getDefaultModule().getModelEnvironment().setLocalMigrationRule(localRule);
|
||||
ApplicationModel.defaultModel().getDefaultModule().modelEnvironment().setDynamicConfiguration(dynamicConfiguration);
|
||||
ApplicationModel.defaultModel().getDefaultModule().modelEnvironment().setLocalMigrationRule(localRule);
|
||||
ApplicationConfig applicationConfig = new ApplicationConfig();
|
||||
applicationConfig.setName("demo-consumer");
|
||||
ApplicationModel.defaultModel().getApplicationConfigManager().setApplication(applicationConfig);
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public class GenericFilter implements Filter, Filter.Listener, ScopeModelAware {
|
|||
} else if (ProtocolUtils.isGsonGenericSerialization(generic)) {
|
||||
args = getGsonGenericArgs(args, method.getGenericParameterTypes());
|
||||
} else if (ProtocolUtils.isJavaGenericSerialization(generic)) {
|
||||
Configuration configuration = ApplicationModel.ofNullable(applicationModel).getModelEnvironment().getConfiguration();
|
||||
Configuration configuration = ApplicationModel.ofNullable(applicationModel).modelEnvironment().getConfiguration();
|
||||
if (!configuration.getBoolean(CommonConstants.ENABLE_NATIVE_JAVA_GENERIC_SERIALIZE, false)) {
|
||||
String notice = "Trigger the safety barrier! " +
|
||||
"Native Java Serializer is not allowed by default." +
|
||||
|
|
|
|||
Loading…
Reference in New Issue