Java Code Examples for com.alibaba.dubbo.common.utils.StringUtils#join()

The following examples show how to use com.alibaba.dubbo.common.utils.StringUtils#join() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RouteUtils.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
static Map<String, String> appendMethodsToUrls(Map<String, String> serviceUrls,
                                               Map<String, Set<String>> url2Methods) {
    // Add method parameters to URL
    Map<String, String> results = new HashMap<String, String>();
    for (Map.Entry<String, Set<String>> entry : url2Methods.entrySet()) {
        String url = entry.getKey();
        String query = serviceUrls.get(url);

        Set<String> methodNames = entry.getValue();
        if (methodNames != null && methodNames.size() > 0) {
            String ms = StringUtils.join(methodNames.toArray(new String[0]), ParseUtils.METHOD_SPLIT);
            query = ParseUtils.replaceParameter(query, "methods", ms);
        }
        results.put(url, query);
    }
    return results;
}
 
Example 2
Source File: RouteUtils.java    From dubbox with Apache License 2.0 6 votes vote down vote up
static Map<String, String> appendMethodsToUrls(Map<String, String> serviceUrls,
                                            Map<String, Set<String>> url2Methods) {
    // 为URL上加上方法参数
    Map<String, String> results = new HashMap<String, String>();
    for (Map.Entry<String, Set<String>> entry : url2Methods.entrySet()) {
        String url = entry.getKey();
        String query = serviceUrls.get(url);
        
        Set<String> methodNames = entry.getValue();
        if (methodNames != null && methodNames.size() > 0) {
            String ms = StringUtils.join(methodNames.toArray(new String[0]), ParseUtils.METHOD_SPLIT);
            query = ParseUtils.replaceParameter(query, "methods", ms);
        }
        results.put(url, query);
    }
    return results;
}
 
Example 3
Source File: RouteUtils.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
static Map<String, String> appendMethodsToUrls(Map<String, String> serviceUrls,
                                            Map<String, Set<String>> url2Methods) {
    // 为URL上加上方法参数
    Map<String, String> results = new HashMap<String, String>();
    for (Map.Entry<String, Set<String>> entry : url2Methods.entrySet()) {
        String url = entry.getKey();
        String query = serviceUrls.get(url);
        
        Set<String> methodNames = entry.getValue();
        if (methodNames != null && methodNames.size() > 0) {
            String ms = StringUtils.join(methodNames.toArray(new String[0]), ParseUtils.METHOD_SPLIT);
            query = ParseUtils.replaceParameter(query, "methods", ms);
        }
        results.put(url, query);
    }
    return results;
}
 
Example 4
Source File: RouteUtils.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
static Map<String, String> appendMethodsToUrls(Map<String, String> serviceUrls,
                                            Map<String, Set<String>> url2Methods) {
    // 为URL上加上方法参数
    Map<String, String> results = new HashMap<String, String>();
    for (Map.Entry<String, Set<String>> entry : url2Methods.entrySet()) {
        String url = entry.getKey();
        String query = serviceUrls.get(url);
        
        Set<String> methodNames = entry.getValue();
        if (methodNames != null && methodNames.size() > 0) {
            String ms = StringUtils.join(methodNames.toArray(new String[0]), ParseUtils.METHOD_SPLIT);
            query = ParseUtils.replaceParameter(query, "methods", ms);
        }
        results.put(url, query);
    }
    return results;
}
 
Example 5
Source File: RouteUtils.java    From dubbox with Apache License 2.0 6 votes vote down vote up
static Map<String, String> appendMethodsToUrls(Map<String, String> serviceUrls,
                                            Map<String, Set<String>> url2Methods) {
    // 为URL上加上方法参数
    Map<String, String> results = new HashMap<String, String>();
    for (Map.Entry<String, Set<String>> entry : url2Methods.entrySet()) {
        String url = entry.getKey();
        String query = serviceUrls.get(url);
        
        Set<String> methodNames = entry.getValue();
        if (methodNames != null && methodNames.size() > 0) {
            String ms = StringUtils.join(methodNames.toArray(new String[0]), ParseUtils.METHOD_SPLIT);
            query = ParseUtils.replaceParameter(query, "methods", ms);
        }
        results.put(url, query);
    }
    return results;
}
 
Example 6
Source File: RouteUtils.java    From dubbox with Apache License 2.0 6 votes vote down vote up
static Map<String, String> appendMethodsToUrls(Map<String, String> serviceUrls,
                                            Map<String, Set<String>> url2Methods) {
    // 为URL上加上方法参数
    Map<String, String> results = new HashMap<String, String>();
    for (Map.Entry<String, Set<String>> entry : url2Methods.entrySet()) {
        String url = entry.getKey();
        String query = serviceUrls.get(url);
        
        Set<String> methodNames = entry.getValue();
        if (methodNames != null && methodNames.size() > 0) {
            String ms = StringUtils.join(methodNames.toArray(new String[0]), ParseUtils.METHOD_SPLIT);
            query = ParseUtils.replaceParameter(query, "methods", ms);
        }
        results.put(url, query);
    }
    return results;
}
 
Example 7
Source File: DubboProtocol.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 8
Source File: DubboProtocol.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * 创建新连接.
 */
private ExchangeClient initClient(URL url) {
    
    // client type setting.
    String str = url.getParameter(Constants.CLIENT_KEY, url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_CLIENT));

    String version = url.getParameter(Constants.DUBBO_VERSION_KEY);
    boolean compatible = (version != null && version.startsWith("1.0."));
    url = url.addParameter(Constants.CODEC_KEY, Version.isCompatibleVersion() && compatible ? COMPATIBLE_CODEC_NAME : DubboCodec.NAME);
    //默认开启heartbeat
    url = url.addParameterIfAbsent(Constants.HEARTBEAT_KEY, String.valueOf(Constants.DEFAULT_HEARTBEAT));
    
    // BIO存在严重性能问题,暂时不允许使用
    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 {
        //设置连接应该是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;
}
 
Example 9
Source File: DubboProtocol.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
/**
 * 创建新连接.
 */
private ExchangeClient initClient(URL url) {
    
    // client type setting.
    String str = url.getParameter(Constants.CLIENT_KEY, url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_CLIENT));

    String version = url.getParameter(Constants.DUBBO_VERSION_KEY);
    boolean compatible = (version != null && version.startsWith("1.0."));
    url = url.addParameter(Constants.CODEC_KEY, Version.isCompatibleVersion() && compatible ? COMPATIBLE_CODEC_NAME : DubboCodec.NAME);
    //默认开启heartbeat
    url = url.addParameterIfAbsent(Constants.HEARTBEAT_KEY, String.valueOf(Constants.DEFAULT_HEARTBEAT));
    
    // BIO存在严重性能问题,暂时不允许使用
    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 {
        //设置连接应该是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;
}
 
Example 10
Source File: MaybeAddClientHeaderParamFromRequest.java    From j360-dubbo-app-all with Apache License 2.0 5 votes vote down vote up
private HttpParam buildParam(HttpServletRequest request) {
    HttpParam param = new HttpParam();

    //params
    Map<String, String[]> queryParamsTemp = request.getParameterMap();
    Map<String, String> queryParams = new HashMap<String, String>(queryParamsTemp.size());
    for (Map.Entry<String, String[]> entry : queryParamsTemp.entrySet()) {
        String key = entry.getKey();
        String[] valueTemp = entry.getValue();
        String value = StringUtils.join(valueTemp,",");
        queryParams.put(key, value);
    }
    param.setParam(queryParams);
    return param;
}
 
Example 11
Source File: DubboProtocol.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
/**
 * 创建新连接.
 */
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);
    //默认开启heartbeat
    url = url.addParameterIfAbsent(Constants.HEARTBEAT_KEY, String.valueOf(Constants.DEFAULT_HEARTBEAT));

    // BIO存在严重性能问题,暂时不允许使用
    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 {
        //设置连接应该是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;
}
 
Example 12
Source File: DubboProtocol.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * 创建新连接.
 */
private ExchangeClient initClient(URL url) {
    
    // client type setting.
    String str = url.getParameter(Constants.CLIENT_KEY, url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_CLIENT));

    String version = url.getParameter(Constants.DUBBO_VERSION_KEY);
    boolean compatible = (version != null && version.startsWith("1.0."));
    url = url.addParameter(Constants.CODEC_KEY, Version.isCompatibleVersion() && compatible ? COMPATIBLE_CODEC_NAME : DubboCodec.NAME);
    //默认开启heartbeat
    url = url.addParameterIfAbsent(Constants.HEARTBEAT_KEY, String.valueOf(Constants.DEFAULT_HEARTBEAT));
    
    // BIO存在严重性能问题,暂时不允许使用
    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 {
        //设置连接应该是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;
}
 
Example 13
Source File: DubboProtocol.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * 创建新连接.
 */
private ExchangeClient initClient(URL url) {
    
    // client type setting.
    String str = url.getParameter(Constants.CLIENT_KEY, url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_CLIENT));

    String version = url.getParameter(Constants.DUBBO_VERSION_KEY);
    boolean compatible = (version != null && version.startsWith("1.0."));
    url = url.addParameter(Constants.CODEC_KEY, Version.isCompatibleVersion() && compatible ? COMPATIBLE_CODEC_NAME : DubboCodec.NAME);
    //默认开启heartbeat
    url = url.addParameterIfAbsent(Constants.HEARTBEAT_KEY, String.valueOf(Constants.DEFAULT_HEARTBEAT));
    
    // BIO存在严重性能问题,暂时不允许使用
    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 {
        //设置连接应该是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;
}