// 是否为泛化接口
if (!ProtocolUtils.isGeneric(generic)) {
String revision = Version.getVersion(interfaceClass, version); if (revision != null && revision.length() > 0) {
map.put(REVISION_KEY, revision); } // 获取接口的方法列表,加入 map
String[] methods = Wrapper.getWrapper(interfaceClass).getMethodNames(); if (methods.length == 0) {
logger.warn("No method found in service interface " + interfaceClass.getName());
map.put(METHODS_KEY, ANY_VALUE); } else {
map.put(METHODS_KEY, StringUtils.join(new HashSet(Arrays.asList(methods)), COMMA_SEPARATOR)); } } map.put(INTERFACE_KEY, interfaceName); // 将 ApplicationConfig、ConsumerConfig、ReferenceConfig 等对象的字段信息添加到 map 中
AbstractConfig.appendParameters(map, getMetrics());
AbstractConfig.appendParameters(map, getApplication());
AbstractConfig.appendParameters(map, getModule());
AbstractConfig.appendParameters(map, consumer);
AbstractConfig.appendParameters(map, this);
Map<String, AsyncMethodInfo> attributes = null; if (CollectionUtils.isNotEmpty(getMethods())) {
attributes = new HashMap<>(); for (MethodConfig methodConfig : getMethods()) {
AbstractConfig.appendParameters(map, methodConfig, methodConfig.getName());
String retryKey = methodConfig.getName() + “.retry”;
if (map.containsKey(retryKey)) {
String retryValue = map.remove(retryKey); if (“false”.equals(retryValue)) {
map.put(methodConfig.getName() + “.retries”, “0”);
} } AsyncMethodInfo asyncMethodInfo = AbstractConfig.convertMethodConfig2AsyncInfo(methodConfig); if (asyncMethodInfo != null) {
attributes.put(methodConfig.getName(), asyncMethodInfo); } } } // 从系统变量中获取服务消费者 ip String hostToRegistry = ConfigUtils.getSystemProperty(DUBBO_IP_TO_REGISTRY); if (StringUtils.isEmpty(hostToRegistry)) {
hostToRegistry = NetUtils.getLocalHost(); } else if (isInvalidLocalHost(hostToRegistry)) {
throw new IllegalArgumentException(“Specified invalid registry ip from property:” + DUBBO_IP_TO_REGISTRY + “, value:” + hostToRegistry);
} map.put(REGISTER_IP_KEY, hostToRegistry); // 存储配置数据
serviceMetadata.getAttachments().putAll(map);
// 创建代理
ref = createProxy(map);
serviceMetadata.setTarget(ref);
serviceMetadata.addAttribute(PROXY_CLASS_REF, ref);
ConsumerModel consumerModel = repository.lookupReferredService(serviceMetadata.getServiceKey()); consumerModel.setProxyObject(ref