org.apache.dubbo.common.URL.removeParameter()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(12.0k)|赞(0)|评价(0)|浏览(75)

本文整理了Java中org.apache.dubbo.common.URL.removeParameter()方法的一些代码示例,展示了URL.removeParameter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URL.removeParameter()方法的具体详情如下:
包路径:org.apache.dubbo.common.URL
类名称:URL
方法名:removeParameter

URL.removeParameter介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-dubbo

@Override
public URL removeParameter(String key) {
  org.apache.dubbo.common.URL result = super.removeParameter(key);
  return new URL(result);
}

代码示例来源:origin: apache/incubator-dubbo

@Override
public URL removeParameter(String key) {
  org.apache.dubbo.common.URL result = super.removeParameter(key);
  return new URL(result);
}

代码示例来源:origin: apache/incubator-dubbo

private URL getRegistryUrl(Invoker<?> originInvoker) {
  URL registryUrl = originInvoker.getUrl();
  if (REGISTRY_PROTOCOL.equals(registryUrl.getProtocol())) {
    String protocol = registryUrl.getParameter(REGISTRY_KEY, DEFAULT_DIRECTORY);
    registryUrl = registryUrl.setProtocol(protocol).removeParameter(REGISTRY_KEY);
  }
  return registryUrl;
}

代码示例来源:origin: apache/incubator-dubbo

private URL getRegistryUrl(Invoker<?> originInvoker) {
  URL registryUrl = originInvoker.getUrl();
  if (REGISTRY_PROTOCOL.equals(registryUrl.getProtocol())) {
    String protocol = registryUrl.getParameter(REGISTRY_KEY, DEFAULT_DIRECTORY);
    registryUrl = registryUrl.setProtocol(protocol).removeParameter(REGISTRY_KEY);
  }
  return registryUrl;
}

代码示例来源:origin: apache/incubator-dubbo

MetadataReportService(URL metadataReportURL) {
  if (Constants.METADATA_REPORT_KEY.equals(metadataReportURL.getProtocol())) {
    String protocol = metadataReportURL.getParameter(Constants.METADATA_REPORT_KEY, Constants.DEFAULT_DIRECTORY);
    metadataReportURL = metadataReportURL.setProtocol(protocol).removeParameter(Constants.METADATA_REPORT_KEY);
  }
  this.metadataReportUrl = metadataReportURL;
  metadataReport = metadataReportFactory.getMetadataReport(this.metadataReportUrl);
}

代码示例来源:origin: apache/incubator-dubbo

MetadataReportService(URL metadataReportURL) {
  if (Constants.METADATA_REPORT_KEY.equals(metadataReportURL.getProtocol())) {
    String protocol = metadataReportURL.getParameter(Constants.METADATA_REPORT_KEY, Constants.DEFAULT_DIRECTORY);
    metadataReportURL = metadataReportURL.setProtocol(protocol).removeParameter(Constants.METADATA_REPORT_KEY);
  }
  this.metadataReportUrl = metadataReportURL;
  metadataReport = metadataReportFactory.getMetadataReport(this.metadataReportUrl);
}

代码示例来源:origin: apache/incubator-dubbo

public AbstractDirectory(URL url, URL consumerUrl, RouterChain<T> routerChain) {
  if (url == null) {
    throw new IllegalArgumentException("url == null");
  }
  if (url.getProtocol().equals(Constants.REGISTRY_PROTOCOL)) {
    Map<String, String> queryMap = StringUtils.parseQueryString(url.getParameterAndDecoded(Constants.REFER_KEY));
    this.url = url.addParameters(queryMap).removeParameter(Constants.MONITOR_KEY);
  } else {
    this.url = url;
  }
  this.consumerUrl = consumerUrl;
  setRouterChain(routerChain);
}

代码示例来源:origin: apache/incubator-dubbo

public AbstractDirectory(URL url, URL consumerUrl, RouterChain<T> routerChain) {
  if (url == null) {
    throw new IllegalArgumentException("url == null");
  }
  if (url.getProtocol().equals(Constants.REGISTRY_PROTOCOL)) {
    Map<String, String> queryMap = StringUtils.parseQueryString(url.getParameterAndDecoded(Constants.REFER_KEY));
    this.url = url.addParameters(queryMap).removeParameter(Constants.MONITOR_KEY);
  } else {
    this.url = url;
  }
  this.consumerUrl = consumerUrl;
  setRouterChain(routerChain);
}

代码示例来源:origin: apache/incubator-dubbo

private URL turnRegistryUrlToConsumerUrl(URL url) {
  // save any parameter in registry that will be useful to the new url.
  String isDefault = url.getParameter(Constants.DEFAULT_KEY);
  if (StringUtils.isNotEmpty(isDefault)) {
    queryMap.put(Constants.REGISTRY_KEY + "." + Constants.DEFAULT_KEY, isDefault);
  }
  return url.setPath(url.getServiceInterface())
      .clearParameters()
      .addParameters(queryMap)
      .removeParameter(Constants.MONITOR_KEY);
}

代码示例来源:origin: apache/incubator-dubbo

@Override
@SuppressWarnings("unchecked")
public <T> Invoker<T> refer(Class<T> type, URL url) throws RpcException {
  url = url.setProtocol(url.getParameter(REGISTRY_KEY, DEFAULT_REGISTRY)).removeParameter(REGISTRY_KEY);
  Registry registry = registryFactory.getRegistry(url);
  if (RegistryService.class.equals(type)) {
    return proxyFactory.getInvoker((T) registry, type, url);
  }
  // group="a,b" or group="*"
  Map<String, String> qs = StringUtils.parseQueryString(url.getParameterAndDecoded(REFER_KEY));
  String group = qs.get(Constants.GROUP_KEY);
  if (group != null && group.length() > 0) {
    if ((COMMA_SPLIT_PATTERN.split(group)).length > 1 || "*".equals(group)) {
      return doRefer(getMergeableCluster(), registry, type, url);
    }
  }
  return doRefer(cluster, registry, type, url);
}

代码示例来源:origin: apache/incubator-dubbo

@Override
@SuppressWarnings("unchecked")
public <T> Invoker<T> refer(Class<T> type, URL url) throws RpcException {
  url = url.setProtocol(url.getParameter(REGISTRY_KEY, DEFAULT_REGISTRY)).removeParameter(REGISTRY_KEY);
  Registry registry = registryFactory.getRegistry(url);
  if (RegistryService.class.equals(type)) {
    return proxyFactory.getInvoker((T) registry, type, url);
  }
  // group="a,b" or group="*"
  Map<String, String> qs = StringUtils.parseQueryString(url.getParameterAndDecoded(REFER_KEY));
  String group = qs.get(Constants.GROUP_KEY);
  if (group != null && group.length() > 0) {
    if ((COMMA_SPLIT_PATTERN.split(group)).length > 1 || "*".equals(group)) {
      return doRefer(getMergeableCluster(), registry, type, url);
    }
  }
  return doRefer(cluster, registry, type, url);
}

代码示例来源:origin: apache/incubator-dubbo

private URL turnRegistryUrlToConsumerUrl(URL url) {
  // save any parameter in registry that will be useful to the new url.
  String isDefault = url.getParameter(Constants.DEFAULT_KEY);
  if (StringUtils.isNotEmpty(isDefault)) {
    queryMap.put(Constants.REGISTRY_KEY + "." + Constants.DEFAULT_KEY, isDefault);
  }
  return url.setPath(url.getServiceInterface())
      .clearParameters()
      .addParameters(queryMap)
      .removeParameter(Constants.MONITOR_KEY);
}

代码示例来源:origin: apache/incubator-dubbo

private static URL getRegistryURL(URL url) {
  return url.setPath(RegistryService.class.getName())
      .removeParameter(Constants.EXPORT_KEY).removeParameter(Constants.REFER_KEY)
      .addParameter(Constants.INTERFACE_KEY, RegistryService.class.getName())
      .addParameter(Constants.CLUSTER_STICKY_KEY, "true")
      .addParameter(Constants.LAZY_CONNECT_KEY, "true")
      .addParameter(Constants.RECONNECT_KEY, "false")
      .addParameterIfAbsent(Constants.TIMEOUT_KEY, "10000")
      .addParameterIfAbsent(Constants.CALLBACK_INSTANCES_LIMIT_KEY, "10000")
      .addParameterIfAbsent(Constants.CONNECT_TIMEOUT_KEY, "10000")
      .addParameter(Constants.METHODS_KEY, StringUtils.join(new HashSet<>(Arrays.asList(Wrapper.getWrapper(RegistryService.class).getDeclaredMethodNames())), ","))
      //.addParameter(Constants.STUB_KEY, RegistryServiceStub.class.getName())
      //.addParameter(Constants.STUB_EVENT_KEY, Boolean.TRUE.toString()) //for event dispatch
      //.addParameter(Constants.ON_DISCONNECT_KEY, "disconnect")
      .addParameter("subscribe.1.callback", "true")
      .addParameter("unsubscribe.1.callback", "false");
}

代码示例来源:origin: apache/incubator-dubbo

private static URL getRegistryURL(URL url) {
  return url.setPath(RegistryService.class.getName())
      .removeParameter(Constants.EXPORT_KEY).removeParameter(Constants.REFER_KEY)
      .addParameter(Constants.INTERFACE_KEY, RegistryService.class.getName())
      .addParameter(Constants.CLUSTER_STICKY_KEY, "true")
      .addParameter(Constants.LAZY_CONNECT_KEY, "true")
      .addParameter(Constants.RECONNECT_KEY, "false")
      .addParameterIfAbsent(Constants.TIMEOUT_KEY, "10000")
      .addParameterIfAbsent(Constants.CALLBACK_INSTANCES_LIMIT_KEY, "10000")
      .addParameterIfAbsent(Constants.CONNECT_TIMEOUT_KEY, "10000")
      .addParameter(Constants.METHODS_KEY, StringUtils.join(new HashSet<>(Arrays.asList(Wrapper.getWrapper(RegistryService.class).getDeclaredMethodNames())), ","))
      //.addParameter(Constants.STUB_KEY, RegistryServiceStub.class.getName())
      //.addParameter(Constants.STUB_EVENT_KEY, Boolean.TRUE.toString()) //for event dispatch
      //.addParameter(Constants.ON_DISCONNECT_KEY, "disconnect")
      .addParameter("subscribe.1.callback", "true")
      .addParameter("unsubscribe.1.callback", "false");
}

代码示例来源:origin: apache/incubator-dubbo

@Override
  public Registry createRegistry(URL url) {
    url = getRegistryURL(url);
    List<URL> urls = new ArrayList<>();
    urls.add(url.removeParameter(Constants.BACKUP_KEY));
    String backup = url.getParameter(Constants.BACKUP_KEY);
    if (backup != null && backup.length() > 0) {
      String[] addresses = Constants.COMMA_SPLIT_PATTERN.split(backup);
      for (String address : addresses) {
        urls.add(url.setAddress(address));
      }
    }
    RegistryDirectory<RegistryService> directory = new RegistryDirectory<>(RegistryService.class, url.addParameter(Constants.INTERFACE_KEY, RegistryService.class.getName()).addParameterAndEncoded(Constants.REFER_KEY, url.toParameterString()));
    Invoker<RegistryService> registryInvoker = cluster.join(directory);
    RegistryService registryService = proxyFactory.getProxy(registryInvoker);
    DubboRegistry registry = new DubboRegistry(registryInvoker, registryService);
    directory.setRegistry(registry);
    directory.setProtocol(protocol);
    directory.setRouterChain(RouterChain.buildChain(url));
    directory.notify(urls);
    directory.subscribe(new URL(Constants.CONSUMER_PROTOCOL, NetUtils.getLocalHost(), 0, RegistryService.class.getName(), url.getParameters()));
    return registry;
  }
}

代码示例来源:origin: apache/incubator-dubbo

@Override
  public Registry createRegistry(URL url) {
    url = getRegistryURL(url);
    List<URL> urls = new ArrayList<>();
    urls.add(url.removeParameter(Constants.BACKUP_KEY));
    String backup = url.getParameter(Constants.BACKUP_KEY);
    if (backup != null && backup.length() > 0) {
      String[] addresses = Constants.COMMA_SPLIT_PATTERN.split(backup);
      for (String address : addresses) {
        urls.add(url.setAddress(address));
      }
    }
    RegistryDirectory<RegistryService> directory = new RegistryDirectory<>(RegistryService.class, url.addParameter(Constants.INTERFACE_KEY, RegistryService.class.getName()).addParameterAndEncoded(Constants.REFER_KEY, url.toParameterString()));
    Invoker<RegistryService> registryInvoker = cluster.join(directory);
    RegistryService registryService = proxyFactory.getProxy(registryInvoker);
    DubboRegistry registry = new DubboRegistry(registryInvoker, registryService);
    directory.setRegistry(registry);
    directory.setProtocol(protocol);
    directory.setRouterChain(RouterChain.buildChain(url));
    directory.notify(urls);
    directory.subscribe(new URL(Constants.CONSUMER_PROTOCOL, NetUtils.getLocalHost(), 0, RegistryService.class.getName(), url.getParameters()));
    return registry;
  }
}

代码示例来源:origin: apache/incubator-dubbo

if (proxy == null) {
  URL referurl = URL.valueOf("callback://" + url.getAddress() + "/" + clazz.getName() + "?" + Constants.INTERFACE_KEY + "=" + clazz.getName());
  referurl = referurl.addParametersIfAbsent(url.getParameters()).removeParameter(Constants.METHODS_KEY);
  if (!isInstancesOverLimit(channel, referurl, clazz.getName(), instid, true)) {
    @SuppressWarnings("rawtypes")

代码示例来源:origin: apache/incubator-dubbo

if (proxy == null) {
  URL referurl = URL.valueOf("callback://" + url.getAddress() + "/" + clazz.getName() + "?" + Constants.INTERFACE_KEY + "=" + clazz.getName());
  referurl = referurl.addParametersIfAbsent(url.getParameters()).removeParameter(Constants.METHODS_KEY);
  if (!isInstancesOverLimit(channel, referurl, clazz.getName(), instid, true)) {
    @SuppressWarnings("rawtypes")

代码示例来源:origin: org.apache.dubbo/dubbo

@Override
public URL removeParameter(String key) {
  org.apache.dubbo.common.URL result = super.removeParameter(key);
  return new URL(result);
}

代码示例来源:origin: org.apache.dubbo/dubbo-registry-api

private URL turnRegistryUrlToConsumerUrl(URL url) {
  // save any parameter in registry that will be useful to the new url.
  String isDefault = url.getParameter(Constants.DEFAULT_KEY);
  if (StringUtils.isNotEmpty(isDefault)) {
    queryMap.put(Constants.REGISTRY_KEY + "." + Constants.DEFAULT_KEY, isDefault);
  }
  return url.setPath(url.getServiceInterface())
      .clearParameters()
      .addParameters(queryMap)
      .removeParameter(Constants.MONITOR_KEY);
}

相关文章

微信公众号

最新文章

更多