| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 
 | private void doExportUrlsFor1Protocol(ProtocolConfig protocolConfig, List<URL> registryURLs) {
 
 String contextPath = protocolConfig.getContextpath();
 if ((contextPath == null || contextPath.length() == 0) && provider != null) {
 contextPath = provider.getContextpath();
 }
 
 String host = this.findConfigedHosts(protocolConfig, registryURLs, map);
 Integer port = this.findConfigedPorts(protocolConfig, name, map);
 URL url = new URL(name, host, port, (contextPath == null || contextPath.length() == 0 ? "" : contextPath + "/") + path, map);
 
 if (ExtensionLoader.getExtensionLoader(ConfiguratorFactory.class)
 .hasExtension(url.getProtocol())) {
 url = ExtensionLoader.getExtensionLoader(ConfiguratorFactory.class)
 .getExtension(url.getProtocol()).getConfigurator(url).configure(url);
 }
 
 String scope = url.getParameter(Constants.SCOPE_KEY);
 
 if (!Constants.SCOPE_NONE.equalsIgnoreCase(scope)) {
 
 if (!Constants.SCOPE_REMOTE.equalsIgnoreCase(scope)) {
 exportLocal(url);
 }
 
 if (!Constants.SCOPE_LOCAL.equalsIgnoreCase(scope)) {
 if (logger.isInfoEnabled()) {
 logger.info("Export dubbo service " + interfaceClass.getName() + " to url " + url);
 }
 if (registryURLs != null && !registryURLs.isEmpty()) {
 
 for (URL registryURL : registryURLs) {
 url = url.addParameterIfAbsent(Constants.DYNAMIC_KEY, registryURL.getParameter(Constants.DYNAMIC_KEY));
 
 URL monitorUrl = loadMonitor(registryURL);
 if (monitorUrl != null) {
 url = url.addParameterAndEncoded(Constants.MONITOR_KEY, monitorUrl.toFullString());
 }
 if (logger.isInfoEnabled()) {
 logger.info("Register dubbo service " + interfaceClass.getName() + " url " + url + " to registry " + registryURL);
 }
 
 String proxy = url.getParameter(Constants.PROXY_KEY);
 if (StringUtils.isNotEmpty(proxy)) {
 registryURL = registryURL.addParameter(Constants.PROXY_KEY, proxy);
 }
 
 Invoker<?> invoker = proxyFactory.getInvoker(ref, (Class) interfaceClass, registryURL.addParameterAndEncoded(Constants.EXPORT_KEY, url.toFullString()));
 
 DelegateProviderMetaDataInvoker wrapperInvoker = new DelegateProviderMetaDataInvoker(invoker, this);
 
 Exporter<?> exporter = protocol.export(wrapperInvoker);
 exporters.add(exporter);
 }
 } else {
 
 Invoker<?> invoker = proxyFactory.getInvoker(ref, (Class) interfaceClass, url);
 
 DelegateProviderMetaDataInvoker wrapperInvoker = new DelegateProviderMetaDataInvoker(invoker, this);
 Exporter<?> exporter = protocol.export(wrapperInvoker);
 exporters.add(exporter);
 }
 }
 }
 this.urls.add(url);
 }
 
 
 private void exportLocal(URL url) {
 if (!Constants.LOCAL_PROTOCOL.equalsIgnoreCase(url.getProtocol())) {
 
 URL local = URL.valueOf(url.toFullString())
 .setProtocol(Constants.LOCAL_PROTOCOL)
 .setHost(LOCALHOST)
 .setPort(0);
 Exporter<?> exporter = protocol.export(
 proxyFactory.getInvoker(ref, (Class) interfaceClass, local));
 exporters.add(exporter);
 logger.info("Export dubbo service " + interfaceClass.getName() + " to local registry");
 }
 }
 
 |