当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.parseQueryString方法代码示例

本文整理汇总了Java中com.alibaba.dubbo.common.utils.StringUtils.parseQueryString方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.parseQueryString方法的具体用法?Java StringUtils.parseQueryString怎么用?Java StringUtils.parseQueryString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.dubbo.common.utils.StringUtils的用法示例。


在下文中一共展示了StringUtils.parseQueryString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertSubscribe

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
public static Map<String, String> convertSubscribe(Map<String, String> subscribe) {
    Map<String, String> newSubscribe = new HashMap<String, String>();
    for (Map.Entry<String, String> entry : subscribe.entrySet()) {
        String serviceName = entry.getKey();
        String serviceQuery = entry.getValue();
        if (! serviceName.contains(":") && ! serviceName.contains("/")) {
            Map<String, String> params = StringUtils.parseQueryString(serviceQuery);
            String group = params.get("group");
            String version = params.get("version");
            params.remove("group");
            params.remove("version");
            String name = serviceName;
            if (group != null && group.length() > 0) {
                name = group + "/" + name;
            }
            if (version != null && version.length() > 0 && ! "0.0.0".equals(version)) {
                name = name + ":" + version;
            }
            newSubscribe.put(name, StringUtils.toQueryString(params));
        } else {
            newSubscribe.put(serviceName, serviceQuery);
        }
    }
    return newSubscribe;
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:26,代码来源:ConvertUtil.java

示例2: toUrl

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
public URL toUrl() {
    String group = null;
    String version = null;
    String path = service;
    int i = path.indexOf("/");
    if (i > 0) {
        group = path.substring(0, i);
        path = path.substring(i + 1);
    }
    i = path.lastIndexOf(":");
    if (i > 0) {
        version = path.substring(i + 1);
        path = path.substring(0, i);
    }
    Map<String, String> param = StringUtils.parseQueryString(parameters);
    param.put(Constants.CATEGORY_KEY, Constants.CONSUMERS_CATEGORY);
    if (group != null) {
        param.put(Constants.GROUP_KEY, group);
    }
    if (version != null) {
        param.put(Constants.VERSION_KEY, version);
    }
    return URL.valueOf(Constants.CONSUMER_PROTOCOL + "://" + address + "/" + path
            + "?" + StringUtils.toQueryString(param));
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:26,代码来源:Consumer.java

示例3: toUrl

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
public URL toUrl() {
    String group = null;
    String version = null;
    String path = service;
    int i = path.indexOf("/");
    if (i > 0) {
        group = path.substring(0, i);
        path = path.substring(i + 1);
    }
    i = path.lastIndexOf(":");
    if (i > 0) {
        version = path.substring(i + 1);
        path = path.substring(0, i);
    }
    Map<String, String> param = StringUtils.parseQueryString(parameters);
    param.put(Constants.CATEGORY_KEY, Constants.CONSUMERS_CATEGORY);
    if (group != null) {
        param.put(Constants.GROUP_KEY, group);
    }
    if (version != null) {
        param.put(Constants.VERSION_KEY, version);
    }
    return URL.valueOf(Constants.CONSUMER_PROTOCOL + "://" + address + "/" + path 
            + "?" + StringUtils.toQueryString(param));
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:26,代码来源:Consumer.java

示例4: getOverridesMock

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
public String getOverridesMock(List<Override> overrides){
	if(overrides != null && overrides.size() > 0) {
 	for(Override override : overrides) {
Map<String, String> params = StringUtils.parseQueryString(override.getParams());
String mock = params.get("mock");
if (mock != null && mock.length() > 0) {
	return mock;
}
 	}
	}
	return "";
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:13,代码来源:Tool.java

示例5: doExecute

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
    protected String doExecute(Map<String,Object> context) throws Exception {
    	Map<String, String[]> params = request.getParameterMap();
        if (params == null || params.size() == 0) {
        	throw new IllegalArgumentException("The url parameters is null! Usage: " + request.getRequestURL().toString() + "?com.xxx.XxxService=http://" + request.getRemoteAddr() + "/xxxService?application=xxx&foo1=123");
        }
        Map<String, Map<String, String>> map = new HashMap<String, Map<String, String>>();
        for (Map.Entry<String, String[]> entry : params.entrySet()) {
            if (entry.getKey() != null && entry.getKey().length() > 0
                    && entry.getValue() != null && entry.getValue().length > 0
                    && entry.getValue()[0] != null && entry.getValue()[0].length() > 0) {
            	if (! currentUser.hasServicePrivilege(entry.getKey())) {
					throw new IllegalStateException("The user " + currentUser.getUsername() + " have no privilege of service " + entry.getKey());
				}
            	String serviceName = entry.getKey();
            	Map<String, String> url2query = CollectionUtils.split(Arrays.asList(entry.getValue()), "?");
            	// check whether url contain application info
            	for(Map.Entry<String, String> e : url2query.entrySet()) {
            	   Map<String, String> query = StringUtils.parseQueryString(e.getValue()); 
            	   String app = query.get("application");
            	   if(StringUtils.isBlank(app)) {
            	       throw new IllegalStateException("No application for service(" + serviceName + "): "
            	               + e.getKey() + "?" + e.getValue());
            	   }
            	}
                map.put(serviceName, url2query);
            }
        }
        if (map.size() > 0) {
//        	providerDAO.register(registryCache.getCurrentRegistry(), request.getRemoteAddr(), operatorAddress, operator, map, false, true);
        }
        return "Register " + map.size() + " services.";
    }
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:34,代码来源:Register.java

示例6: show

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
public void show(Long[] ids, Map<String, Object> context) {
    String version =(String)context.get("version");
    if (version != null && version.length() > 0) {
        List<Provider> providers = providerService.findAll();
        List<Consumer> consumers = consumerService.findAll();
        Set<String> parametersSet = new HashSet<String>();
        Set<String> applications = new HashSet<String>();
        for (Provider provider : providers) {
            parametersSet.add(provider.getParameters());
        }
        for (Consumer consumer : consumers) {
            parametersSet.add(consumer.getParameters());
        }
        Iterator<String> temp = parametersSet.iterator();
        while (temp.hasNext()) {
            Map<String, String> parameter = StringUtils.parseQueryString(temp.next());
            if (parameter != null) {
                String dubbo = parameter.get("dubbo");
                if(dubbo == null) dubbo = "0.0.0";
                String application = parameter.get("application");
                if (version.equals(dubbo)) {
                    applications.add(application);
                }
            }
        }
        context.put("applications", applications);
    }
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:29,代码来源:Versions.java

示例7: getProviderWeight

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
public static int getProviderWeight(Provider provider, List<Override> oList) {
    for (Override o : oList) {
        if (o.isMatch(provider)) {
            Map<String, String> params = StringUtils.parseQueryString(o.getParams());
            String weight = params.get(Constants.WEIGHT_KEY);
            if (weight != null && weight.length() > 0) {
                return Integer.parseInt(weight);
            }
        }
    }
    return provider.getWeight();
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:13,代码来源:Tool.java

示例8: isProviderEnabled

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
public static boolean isProviderEnabled(Provider provider, List<Override> oList){
	for(Override o : oList){
		if (o.isMatch(provider)) {
 		Map<String, String> params = StringUtils.parseQueryString(o.getParams());
 		String disbaled = params.get(Constants.DISABLED_KEY);
     	if(disbaled != null && disbaled.length() > 0){
     		return ! "true".equals(disbaled);
     	}
		}
	}
	return provider.isEnabled();
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:13,代码来源:Tool.java

示例9: overridesToLoadBalances

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
public static List<LoadBalance> overridesToLoadBalances(List<Override> overrides){
    List<LoadBalance> loadBalances = new ArrayList<LoadBalance>();
    if(overrides == null){
        return loadBalances;
    }
 for(Override o : overrides){
        if(StringUtils.isEmpty(o.getParams())){
            continue;
        }else{
            Map<String,String> params = StringUtils.parseQueryString(o.getParams());
            for(Map.Entry<String, String> entry : params.entrySet()){
                if(entry.getKey().endsWith("loadbalance")){
                    LoadBalance loadBalance = new LoadBalance();
                    String method = null;
                    if(entry.getKey().endsWith(".loadbalance")){
                        method = entry.getKey().split(".loadbalance")[0];
                    }else{
                        method = "*";
                    }
                   
                    loadBalance.setMethod(method);
                    loadBalance.setId(o.getId());
                    loadBalance.setService(o.getService());
                    loadBalance.setStrategy(entry.getValue());
                    loadBalances.add(loadBalance);
                   
                }
            }
        }
    }
    return loadBalances;
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:33,代码来源:OverrideUtils.java

示例10: getProviderWeight

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
public static int getProviderWeight(Provider provider, List<Override> oList) {
	for(Override o : oList){
		if (o.isMatch(provider)) {
 		Map<String, String> params = StringUtils.parseQueryString(o.getParams());
 		String weight = params.get(Constants.WEIGHT_KEY);
     	if(weight != null && weight.length() > 0){
     		return Integer.parseInt(weight);
     	}
		}
	}
	return provider.getWeight();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:13,代码来源:Tool.java

示例11: show

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
public void show(Long[] ids, Map<String, Object> context) {
    String version = (String) context.get("version");
    if (version != null && version.length() > 0) {
        List<Provider> providers = providerService.findAll();
        List<Consumer> consumers = consumerService.findAll();
        Set<String> parametersSet = new HashSet<String>();
        Set<String> applications = new HashSet<String>();
        for (Provider provider : providers) {
            parametersSet.add(provider.getParameters());
        }
        for (Consumer consumer : consumers) {
            parametersSet.add(consumer.getParameters());
        }
        Iterator<String> temp = parametersSet.iterator();
        while (temp.hasNext()) {
            Map<String, String> parameter = StringUtils.parseQueryString(temp.next());
            if (parameter != null) {
                String dubbo = parameter.get("dubbo");
                if (dubbo == null) dubbo = "0.0.0";
                String application = parameter.get("application");
                if (version.equals(dubbo)) {
                    applications.add(application);
                }
            }
        }
        context.put("applications", applications);
    }
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:29,代码来源:Versions.java

示例12: disableProvider

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
public void disableProvider(Long id) {
    if(id == null) {
        throw new IllegalStateException("no provider id");
    }
    
    Provider oldProvider = findProvider(id);
    if(oldProvider == null) {
        throw new IllegalStateException("Provider was changed!");
    }
    
    if (oldProvider.isDynamic()) {
     //保证disable的override唯一
     if(oldProvider.isEnabled()){
     	Override override = new Override();
     	override.setAddress(oldProvider.getAddress());
     	override.setService(oldProvider.getService());
     	override.setEnabled(true);
     	override.setParams(Constants.DISABLED_KEY+"=true");
     	overrideService.saveOverride(override);
     	return;
     }
     List<Override> oList = overrideService.findByServiceAndAddress(oldProvider.getService(), oldProvider.getAddress());
    
     for(Override o : oList){
     	Map<String, String> params = StringUtils.parseQueryString(o.getParams());
     	if(params.containsKey(Constants.DISABLED_KEY)){
     		if(params.get(Constants.DISABLED_KEY) .equals("false")){
     			overrideService.deleteOverride(o.getId());
     		}
     	}
     }
    } else {
    	oldProvider.setEnabled(false);
    	updateProvider(oldProvider);
    }
    
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:38,代码来源:ProviderServiceImpl.java

示例13: index

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
public void index(Map<String, Object> context) {
    List<Provider> providers = providerService.findAll();
    List<Consumer> consumers = consumerService.findAll();
    Set<String> parametersSet = new HashSet<String>();
    for (Provider provider : providers) {
        parametersSet.add(provider.getParameters());
    }
    for (Consumer consumer : consumers) {
        parametersSet.add(consumer.getParameters());
    }
    Map<String, Set<String>> versions = new HashMap<String, Set<String>>();
    Iterator<String> temp = parametersSet.iterator();
    while (temp.hasNext()) {
        Map<String, String> parameter = StringUtils.parseQueryString(temp.next());
        if (parameter != null) {
            String dubbo = parameter.get("dubbo");
            if (dubbo == null) dubbo = "0.0.0";
            String application = parameter.get("application");
            if (versions.get(dubbo) == null) {
                Set<String> apps = new HashSet<String>();
                versions.put(dubbo, apps);
            }
            versions.get(dubbo).add(application);
        }
    }
    context.put("versions", versions);
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:28,代码来源:Versions.java

示例14: toUrl

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
public URL toUrl() {
    String group = null;
    String version = null;
    String path = service;
    int i = path.indexOf("/");
    if (i > 0) {
        group = path.substring(0, i);
        path = path.substring(i + 1);
    }
    i = path.lastIndexOf(":");
    if (i > 0) {
        version = path.substring(i + 1);
        path = path.substring(0, i);
    }
    StringBuilder sb = new StringBuilder();
    sb.append(Constants.OVERRIDE_PROTOCOL);
    sb.append("://");
    if(! StringUtils.isBlank(address) && ! Constants.ANY_VALUE.equals(address)) {
        sb.append(address);
    } else {
        sb.append(Constants.ANYHOST_VALUE);
    }
    sb.append("/");
    sb.append(path);
    sb.append("?");
    Map<String, String> param = StringUtils.parseQueryString(params);
    param.put(Constants.CATEGORY_KEY, Constants.CONFIGURATORS_CATEGORY);
    param.put(Constants.ENABLED_KEY, String.valueOf(isEnabled()));
    param.put(Constants.DYNAMIC_KEY, "false");
    if(! StringUtils.isBlank(application) && ! Constants.ANY_VALUE.equals(application)) {
        param.put(Constants.APPLICATION_KEY, application);
    }
    if (group != null) {
        param.put(Constants.GROUP_KEY, group);
    }
    if (version != null) {
        param.put(Constants.VERSION_KEY, version);
    }
    sb.append(StringUtils.toQueryString(param));
    return URL.valueOf(sb.toString());
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:42,代码来源:Override.java

示例15: parseParameters

import com.alibaba.dubbo.common.utils.StringUtils; //导入方法依赖的package包/类
public static Parameters parseParameters(String query) {
    return new Parameters(StringUtils.parseQueryString(query));
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:4,代码来源:Parameters.java


注:本文中的com.alibaba.dubbo.common.utils.StringUtils.parseQueryString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。