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

x33g5p2x  于2022-01-31 转载在 其他  
字(15.2k)|赞(0)|评价(0)|浏览(93)

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

URL.removeParameter介绍

暂无

代码示例

代码示例来源:origin: dubboclub/dubbo-plus

private URL removeTransporterParameter(URL url){
  url = url.removeParameter(Constants.SERVER_KEY);
  url = url.removeParameter(Constants.TRANSPORTER_KEY);
  url = url.removeParameter(Constants.DEFAULT_KEY_PREFIX+ Constants.TRANSPORTER_KEY);
  url = url.removeParameter(Constants.DEFAULT_KEY_PREFIX+ Constants.SERVER_KEY);
  return url;
}

代码示例来源:origin: com.alibaba/dubbo

/**
 * Return the url that is registered to the registry and filter the url parameter once
 *
 * @param originInvoker
 * @return
 */
private URL getRegisteredProviderUrl(final Invoker<?> originInvoker) {
  URL providerUrl = getProviderUrl(originInvoker);
  //The address you see at the registry
  return providerUrl.removeParameters(getFilteredKeys(providerUrl))
      .removeParameter(Constants.MONITOR_KEY)
      .removeParameter(Constants.BIND_IP_KEY)
      .removeParameter(Constants.BIND_PORT_KEY)
      .removeParameter(QOS_ENABLE)
      .removeParameter(QOS_PORT)
      .removeParameter(ACCEPT_FOREIGN_IP)
      .removeParameter(VALIDATION_KEY);
}

代码示例来源:origin: dubboclub/dubbo-plus

private URL removeTransporterParameter(URL url){
  url = url.removeParameter(Constants.SERVER_KEY);
  url = url.removeParameter(Constants.TRANSPORTER_KEY);
  url = url.removeParameter(Constants.DEFAULT_KEY_PREFIX+ Constants.TRANSPORTER_KEY);
  url = url.removeParameter(Constants.DEFAULT_KEY_PREFIX+ Constants.SERVER_KEY);
  return url;
}

代码示例来源:origin: linux-china/dubbo3

/**
 * 返回注册到注册中心的URL,对URL参数进行一次过滤
 * @param originInvoker
 * @return
 */
private URL getRegistedProviderUrl(final Invoker<?> originInvoker){
  URL providerUrl = getProviderUrl(originInvoker);
  //注册中心看到的地址
  final URL registedProviderUrl = providerUrl.removeParameters(getFilteredKeys(providerUrl)).removeParameter(Constants.MONITOR_KEY);
  return registedProviderUrl;
}

代码示例来源:origin: com.alibaba/dubbo

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

代码示例来源:origin: linux-china/dubbo3

/**
 * 返回注册到注册中心的URL,对URL参数进行一次过滤
 * @param originInvoker
 * @return
 */
private URL getRegistedProviderUrl(final Invoker<?> originInvoker){
  URL providerUrl = getProviderUrl(originInvoker);
  //注册中心看到的地址
  final URL registedProviderUrl = providerUrl.removeParameters(getFilteredKeys(providerUrl)).removeParameter(Constants.MONITOR_KEY);
  return registedProviderUrl;
}

代码示例来源:origin: com.alibaba/dubbo-registry-api

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

代码示例来源:origin: com.alibaba/dubbo-registry-api

public RegistryDirectory(Class<T> serviceType, URL url) {
  super(url);
  if (serviceType == null)
    throw new IllegalArgumentException("service type is null.");
  if (url.getServiceKey() == null || url.getServiceKey().length() == 0)
    throw new IllegalArgumentException("registry serviceKey is null.");
  this.serviceType = serviceType;
  this.serviceKey = url.getServiceKey();
  this.queryMap = StringUtils.parseQueryString(url.getParameterAndDecoded(Constants.REFER_KEY));
  this.overrideDirectoryUrl = this.directoryUrl = url.setPath(url.getServiceInterface()).clearParameters().addParameters(queryMap).removeParameter(Constants.MONITOR_KEY);
  String group = directoryUrl.getParameter(Constants.GROUP_KEY, "");
  this.multiGroup = group != null && ("*".equals(group) || group.contains(","));
  String methods = queryMap.get(Constants.METHODS_KEY);
  this.serviceMethods = methods == null ? null : Constants.COMMA_SPLIT_PATTERN.split(methods);
}

代码示例来源:origin: remoting/dubbox

public RegistryDirectory(Class<T> serviceType, URL url) {
  super(url);
  if(serviceType == null )
    throw new IllegalArgumentException("service type is null.");
  if(url.getServiceKey() == null || url.getServiceKey().length() == 0)
    throw new IllegalArgumentException("registry serviceKey is null.");
  this.serviceType = serviceType;
  this.serviceKey = url.getServiceKey();
  this.queryMap = StringUtils.parseQueryString(url.getParameterAndDecoded(Constants.REFER_KEY));
  this.overrideDirectoryUrl = this.directoryUrl = url.setPath(url.getServiceInterface()).clearParameters().addParameters(queryMap).removeParameter(Constants.MONITOR_KEY);
  String group = directoryUrl.getParameter( Constants.GROUP_KEY, "" );
  this.multiGroup = group != null && ("*".equals(group) || group.contains( "," ));
  String methods = queryMap.get(Constants.METHODS_KEY);
  this.serviceMethods = methods == null ? null : Constants.COMMA_SPLIT_PATTERN.split(methods);
}

代码示例来源:origin: com.alibaba/dubbo

public RegistryDirectory(Class<T> serviceType, URL url) {
  super(url);
  if (serviceType == null)
    throw new IllegalArgumentException("service type is null.");
  if (url.getServiceKey() == null || url.getServiceKey().length() == 0)
    throw new IllegalArgumentException("registry serviceKey is null.");
  this.serviceType = serviceType;
  this.serviceKey = url.getServiceKey();
  this.queryMap = StringUtils.parseQueryString(url.getParameterAndDecoded(Constants.REFER_KEY));
  this.overrideDirectoryUrl = this.directoryUrl = url.setPath(url.getServiceInterface()).clearParameters().addParameters(queryMap).removeParameter(Constants.MONITOR_KEY);
  String group = directoryUrl.getParameter(Constants.GROUP_KEY, "");
  this.multiGroup = group != null && ("*".equals(group) || group.contains(","));
  String methods = queryMap.get(Constants.METHODS_KEY);
  this.serviceMethods = methods == null ? null : Constants.COMMA_SPLIT_PATTERN.split(methods);
}

代码示例来源:origin: remoting/dubbox

public RegistryDirectory(Class<T> serviceType, URL url) {
  super(url);
  if(serviceType == null )
    throw new IllegalArgumentException("service type is null.");
  if(url.getServiceKey() == null || url.getServiceKey().length() == 0)
    throw new IllegalArgumentException("registry serviceKey is null.");
  this.serviceType = serviceType;
  this.serviceKey = url.getServiceKey();
  this.queryMap = StringUtils.parseQueryString(url.getParameterAndDecoded(Constants.REFER_KEY));
  this.overrideDirectoryUrl = this.directoryUrl = url.setPath(url.getServiceInterface()).clearParameters().addParameters(queryMap).removeParameter(Constants.MONITOR_KEY);
  String group = directoryUrl.getParameter( Constants.GROUP_KEY, "" );
  this.multiGroup = group != null && ("*".equals(group) || group.contains( "," ));
  String methods = queryMap.get(Constants.METHODS_KEY);
  this.serviceMethods = methods == null ? null : Constants.COMMA_SPLIT_PATTERN.split(methods);
}

代码示例来源:origin: linux-china/dubbo3

/**
 * 根据invoker的地址获取registry实例
 * @param originInvoker
 * @return
 */
private Registry getRegistry(final Invoker<?> originInvoker){
  URL registryUrl = originInvoker.getUrl();
  if (Constants.REGISTRY_PROTOCOL.equals(registryUrl.getProtocol())) {
    String protocol = registryUrl.getParameter(Constants.REGISTRY_KEY, Constants.DEFAULT_DIRECTORY);
    registryUrl = registryUrl.setProtocol(protocol).removeParameter(Constants.REGISTRY_KEY);
  }
  return registryFactory.getRegistry(registryUrl);
}

代码示例来源:origin: linux-china/dubbo3

/**
 * 根据invoker的地址获取registry实例
 * @param originInvoker
 * @return
 */
private Registry getRegistry(final Invoker<?> originInvoker){
  URL registryUrl = originInvoker.getUrl();
  if (Constants.REGISTRY_PROTOCOL.equals(registryUrl.getProtocol())) {
    String protocol = registryUrl.getParameter(Constants.REGISTRY_KEY, Constants.DEFAULT_DIRECTORY);
    registryUrl = registryUrl.setProtocol(protocol).removeParameter(Constants.REGISTRY_KEY);
  }
  return registryFactory.getRegistry(registryUrl);
}

代码示例来源:origin: com.alibaba/dubbo

@Override
@SuppressWarnings("unchecked")
public <T> Invoker<T> refer(Class<T> type, URL url) throws RpcException {
  url = url.setProtocol(url.getParameter(Constants.REGISTRY_KEY, Constants.DEFAULT_REGISTRY)).removeParameter(Constants.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(Constants.REFER_KEY));
  String group = qs.get(Constants.GROUP_KEY);
  if (group != null && group.length() > 0) {
    if ((Constants.COMMA_SPLIT_PATTERN.split(group)).length > 1
        || "*".equals(group)) {
      return doRefer(getMergeableCluster(), registry, type, url);
    }
  }
  return doRefer(cluster, registry, type, url);
}

代码示例来源:origin: linux-china/dubbo3

@SuppressWarnings("unchecked")
public <T> Invoker<T> refer(Class<T> type, URL url) throws RpcException {
  url = url.setProtocol(url.getParameter(Constants.REGISTRY_KEY, Constants.DEFAULT_REGISTRY)).removeParameter(Constants.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(Constants.REFER_KEY));
  String group = qs.get(Constants.GROUP_KEY);
  if (group != null && group.length() > 0 ) {
    if ( ( Constants.COMMA_SPLIT_PATTERN.split( group ) ).length > 1
        || "*".equals( group ) ) {
      return doRefer( getMergeableCluster(), registry, type, url );
    }
  }
  return doRefer(cluster, registry, type, url);
}

代码示例来源:origin: com.alibaba/dubbo-registry-api

@Override
@SuppressWarnings("unchecked")
public <T> Invoker<T> refer(Class<T> type, URL url) throws RpcException {
  url = url.setProtocol(url.getParameter(Constants.REGISTRY_KEY, Constants.DEFAULT_REGISTRY)).removeParameter(Constants.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(Constants.REFER_KEY));
  String group = qs.get(Constants.GROUP_KEY);
  if (group != null && group.length() > 0) {
    if ((Constants.COMMA_SPLIT_PATTERN.split(group)).length > 1
        || "*".equals(group)) {
      return doRefer(getMergeableCluster(), registry, type, url);
    }
  }
  return doRefer(cluster, registry, type, url);
}

代码示例来源:origin: com.alibaba/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<String>(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: remoting/dubbox

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<String>(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: com.alibaba/dubbo-registry-default

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<String>(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: net.jahhan/dubbo-registry-default

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<String>(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");
  }
}

相关文章

微信公众号

最新文章

更多