4)方法1.2,AbstractInterfaceConfig类#refresh()方法
// 刷新XxConfig// 一个XxConfig对象的属性可能是有值的,也可能是没有值的,这时需要从其他位置获取属性值,来进行属性的覆盖// 覆盖的优先级,从大到小为系统变量->配置中心应用配置->配置中心全局配置->注解或xml中定义->dubbo.properties文件// 以ServiceConfig为例,ServiceConfig中包括很多属性 , 比如timeout// 但是在定义一个Service时,如果在注解上没有配置timeout,那么就会其他地方获取timeout的配置// 比如可以从系统变量->配置中心应用配置->配置中心全局配置->注解或xml中定义->dubbo.properties文件// refresh是刷新,将当前ServiceConfig上的set方法所对应的属性更新为优先级最高的值public void refresh() {try {CompositeConfiguration compositeConfiguration = Environment.getInstance().getConfiguration(getPrefix(), getId());// 表示XxConfig对象本身- AbstractConfigConfiguration config = new ConfigConfigurationAdapter(this);//设置顺序,if (Environment.getInstance().isConfigCenterFirst()) {// The sequence would be: SystemConfiguration -> AppExternalConfiguration -> ExternalConfiguration -> AbstractConfig -> PropertiesConfigurationcompositeConfiguration.addConfiguration(4, config);} else {// The sequence would be: SystemConfiguration -> AbstractConfig -> AppExternalConfiguration -> ExternalConfiguration -> PropertiesConfigurationcompositeConfiguration.addConfiguration(2, config);}// loop methods, get override value and set the new value back to method//Method[] methods = getClass().getMethods();for (Method method : methods) {// 是不是setXX()方法if (MethodUtils.isSetter(method)) {// 获取xx配置项的valueString value = https://www.huyubaike.com/biancheng/StringUtils.trim(compositeConfiguration.getString(extractPropertyName(getClass(), method)));// isTypeMatch() is called to avoid duplicate and incorrect update, for example, we have two'setGeneric' methods in ReferenceConfig.if (StringUtils.isNotEmpty(value) && ClassUtils.isTypeMatch(method.getParameterTypes()[0], value)) {method.invoke(this, ClassUtils.convertPrimitive(method.getParameterTypes()[0], value));}// 是不是setParameters()方法} else if (isParametersSetter(method)) {// 获取parameter配置项的valueString value = https://www.huyubaike.com/biancheng/StringUtils.trim(compositeConfiguration.getString(extractPropertyName(getClass(), method)));if (StringUtils.isNotEmpty(value)) {Map
推荐阅读
- 四 SpringBoot - 整合Mybatis,逆向工程,JPA
- 华为手环6怎么样_华为手环6功能详解
- logback.xml详解
- iptables使用详解
- 一篇文章带你掌握主流办公框架——SpringBoot
- RAID5 IO处理之条带读代码详解
- RAID5 IO处理之写请求代码详解
- RAID5 IO处理之重构代码详解
- RAID5 IO处理之replace代码详解
- Spring的同一个服务为什么会加载多次?