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

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

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

URL.addParameterIfAbsent介绍

暂无

代码示例

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

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

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

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

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

public static ExchangeServer bind(URL url, ExchangeHandler handler) throws RemotingException {
  if (url == null) {
    throw new IllegalArgumentException("url == null");
  }
  if (handler == null) {
    throw new IllegalArgumentException("handler == null");
  }
  url = url.addParameterIfAbsent(Constants.CODEC_KEY, "exchange");
  return getExchanger(url).bind(url, handler);
}

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

public static ExchangeClient connect(URL url, ExchangeHandler handler) throws RemotingException {
  if (url == null) {
    throw new IllegalArgumentException("url == null");
  }
  if (handler == null) {
    throw new IllegalArgumentException("handler == null");
  }
  url = url.addParameterIfAbsent(Constants.CODEC_KEY, "exchange");
  return getExchanger(url).connect(url, handler);
}

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

public static ExchangeServer bind(URL url, ExchangeHandler handler) throws RemotingException {
  if (url == null) {
    throw new IllegalArgumentException("url == null");
  }
  if (handler == null) {
    throw new IllegalArgumentException("handler == null");
  }
  url = url.addParameterIfAbsent(Constants.CODEC_KEY, "exchange");
  return getExchanger(url).bind(url, handler);
}

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

public static ExchangeClient connect(URL url, ExchangeHandler handler) throws RemotingException {
  if (url == null) {
    throw new IllegalArgumentException("url == null");
  }
  if (handler == null) {
    throw new IllegalArgumentException("handler == null");
  }
  url = url.addParameterIfAbsent(Constants.CODEC_KEY, "exchange");
  return getExchanger(url).connect(url, handler);
}

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

protected static ChannelHandler wrapChannelHandler(URL url, ChannelHandler handler) {
  url = ExecutorUtil.setThreadName(url, CLIENT_THREAD_POOL_NAME);
  url = url.addParameterIfAbsent(Constants.THREADPOOL_KEY, Constants.DEFAULT_CLIENT_THREADPOOL);
  return ChannelHandlers.wrap(handler, url);
}

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

protected static ChannelHandler wrapChannelHandler(URL url, ChannelHandler handler) {
  url = ExecutorUtil.setThreadName(url, CLIENT_THREAD_POOL_NAME);
  url = url.addParameterIfAbsent(Constants.THREADPOOL_KEY, Constants.DEFAULT_CLIENT_THREADPOOL);
  return ChannelHandlers.wrap(handler, url);
}

代码示例来源: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

private ExchangeServer createServer(URL url) {
  // send readonly event when server closes, it's enabled by default
  url = url.addParameterIfAbsent(Constants.CHANNEL_READONLYEVENT_SENT_KEY, Boolean.TRUE.toString());
  // enable heartbeat by default
  url = url.addParameterIfAbsent(Constants.HEARTBEAT_KEY, String.valueOf(Constants.DEFAULT_HEARTBEAT));
  String str = url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_SERVER);
  if (str != null && str.length() > 0 && !ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(str)) {
    throw new RpcException("Unsupported server type: " + str + ", url: " + url);
  }
  url = url.addParameter(Constants.CODEC_KEY, DubboCodec.NAME);
  ExchangeServer server;
  try {
    server = Exchangers.bind(url, requestHandler);
  } catch (RemotingException e) {
    throw new RpcException("Fail to start server(url: " + url + ") " + e.getMessage(), e);
  }
  str = url.getParameter(Constants.CLIENT_KEY);
  if (str != null && str.length() > 0) {
    Set<String> supportedTypes = ExtensionLoader.getExtensionLoader(Transporter.class).getSupportedExtensions();
    if (!supportedTypes.contains(str)) {
      throw new RpcException("Unsupported client type: " + str);
    }
  }
  return server;
}

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

private ExchangeServer createServer(URL url) {
  // send readonly event when server closes, it's enabled by default
  url = url.addParameterIfAbsent(Constants.CHANNEL_READONLYEVENT_SENT_KEY, Boolean.TRUE.toString());
  // enable heartbeat by default
  url = url.addParameterIfAbsent(Constants.HEARTBEAT_KEY, String.valueOf(Constants.DEFAULT_HEARTBEAT));
  String str = url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_SERVER);
  if (str != null && str.length() > 0 && !ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(str)) {
    throw new RpcException("Unsupported server type: " + str + ", url: " + url);
  }
  url = url.addParameter(Constants.CODEC_KEY, DubboCodec.NAME);
  ExchangeServer server;
  try {
    server = Exchangers.bind(url, requestHandler);
  } catch (RemotingException e) {
    throw new RpcException("Fail to start server(url: " + url + ") " + e.getMessage(), e);
  }
  str = url.getParameter(Constants.CLIENT_KEY);
  if (str != null && str.length() > 0) {
    Set<String> supportedTypes = ExtensionLoader.getExtensionLoader(Transporter.class).getSupportedExtensions();
    if (!supportedTypes.contains(str)) {
      throw new RpcException("Unsupported client type: " + str);
    }
  }
  return server;
}

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

private ExchangeServer getServer(URL url) {
  // enable sending readonly event when server closes by default
  url = url.addParameterIfAbsent(Constants.CHANNEL_READONLYEVENT_SENT_KEY, Boolean.TRUE.toString());
  String str = url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_SERVER);
  if (str != null && str.length() > 0 && !ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(str)) {
    throw new RpcException("Unsupported server type: " + str + ", url: " + url);
  }
  ExchangeServer server;
  try {
    server = Exchangers.bind(url, handler);
  } catch (RemotingException e) {
    throw new RpcException("Fail to start server(url: " + url + ") " + e.getMessage(), e);
  }
  str = url.getParameter(Constants.CLIENT_KEY);
  if (str != null && str.length() > 0) {
    Set<String> supportedTypes = ExtensionLoader.getExtensionLoader(Transporter.class).getSupportedExtensions();
    if (!supportedTypes.contains(str)) {
      throw new RpcException("Unsupported client type: " + str);
    }
  }
  return server;
}

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

private ExchangeServer getServer(URL url) {
  // enable sending readonly event when server closes by default
  url = url.addParameterIfAbsent(Constants.CHANNEL_READONLYEVENT_SENT_KEY, Boolean.TRUE.toString());
  String str = url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_SERVER);
  if (str != null && str.length() > 0 && !ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(str)) {
    throw new RpcException("Unsupported server type: " + str + ", url: " + url);
  }
  ExchangeServer server;
  try {
    server = Exchangers.bind(url, handler);
  } catch (RemotingException e) {
    throw new RpcException("Fail to start server(url: " + url + ") " + e.getMessage(), e);
  }
  str = url.getParameter(Constants.CLIENT_KEY);
  if (str != null && str.length() > 0) {
    Set<String> supportedTypes = ExtensionLoader.getExtensionLoader(Transporter.class).getSupportedExtensions();
    if (!supportedTypes.contains(str)) {
      throw new RpcException("Unsupported client type: " + str);
    }
  }
  return server;
}

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

/**
 * Create new connection
 */
private ExchangeClient initClient(URL url) {
  // client type setting.
  String str = url.getParameter(Constants.CLIENT_KEY, url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_CLIENT));
  url = url.addParameter(Constants.CODEC_KEY, DubboCodec.NAME);
  // enable heartbeat by default
  url = url.addParameterIfAbsent(Constants.HEARTBEAT_KEY, String.valueOf(Constants.DEFAULT_HEARTBEAT));
  // BIO is not allowed since it has severe performance issue.
  if (str != null && str.length() > 0 && !ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(str)) {
    throw new RpcException("Unsupported client type: " + str + "," +
        " supported client type is " + StringUtils.join(ExtensionLoader.getExtensionLoader(Transporter.class).getSupportedExtensions(), " "));
  }
  ExchangeClient client;
  try {
    // connection should be lazy
    if (url.getParameter(Constants.LAZY_CONNECT_KEY, false)) {
      client = new LazyConnectExchangeClient(url, requestHandler);
    } else {
      client = Exchangers.connect(url, requestHandler);
    }
  } catch (RemotingException e) {
    throw new RpcException("Fail to create remoting client for service(" + url + "): " + e.getMessage(), e);
  }
  return client;
}

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

/**
 * Create new connection
 */
private ExchangeClient initClient(URL url) {
  // client type setting.
  String str = url.getParameter(Constants.CLIENT_KEY, url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_CLIENT));
  url = url.addParameter(Constants.CODEC_KEY, DubboCodec.NAME);
  // enable heartbeat by default
  url = url.addParameterIfAbsent(Constants.HEARTBEAT_KEY, String.valueOf(Constants.DEFAULT_HEARTBEAT));
  // BIO is not allowed since it has severe performance issue.
  if (str != null && str.length() > 0 && !ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(str)) {
    throw new RpcException("Unsupported client type: " + str + "," +
        " supported client type is " + StringUtils.join(ExtensionLoader.getExtensionLoader(Transporter.class).getSupportedExtensions(), " "));
  }
  ExchangeClient client;
  try {
    // connection should be lazy
    if (url.getParameter(Constants.LAZY_CONNECT_KEY, false)) {
      client = new LazyConnectExchangeClient(url, requestHandler);
    } else {
      client = Exchangers.connect(url, requestHandler);
    }
  } catch (RemotingException e) {
    throw new RpcException("Fail to create remoting client for service(" + url + "): " + e.getMessage(), e);
  }
  return client;
}

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

url = url.addParameterIfAbsent(Constants.DYNAMIC_KEY, registryURL.getParameter(Constants.DYNAMIC_KEY));
URL monitorUrl = loadMonitor(registryURL);
if (monitorUrl != null) {

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

url = url.addParameterIfAbsent(Constants.DYNAMIC_KEY, registryURL.getParameter(Constants.DYNAMIC_KEY));
URL monitorUrl = loadMonitor(registryURL);
if (monitorUrl != null) {

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

public static ExchangeClient connect(URL url, ExchangeHandler handler) throws RemotingException {
  if (url == null) {
    throw new IllegalArgumentException("url == null");
  }
  if (handler == null) {
    throw new IllegalArgumentException("handler == null");
  }
  url = url.addParameterIfAbsent(Constants.CODEC_KEY, "exchange");
  return getExchanger(url).connect(url, handler);
}

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

protected static ChannelHandler wrapChannelHandler(URL url, ChannelHandler handler) {
  url = ExecutorUtil.setThreadName(url, CLIENT_THREAD_POOL_NAME);
  url = url.addParameterIfAbsent(Constants.THREADPOOL_KEY, Constants.DEFAULT_CLIENT_THREADPOOL);
  return ChannelHandlers.wrap(handler, url);
}

相关文章

微信公众号

最新文章

更多