Java Code Examples for com.alibaba.dubbo.common.URL#decode()

The following examples show how to use com.alibaba.dubbo.common.URL#decode() . 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: Overrides.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
private String[] parseMock(String mock) {
    mock = URL.decode(mock);
    String force;
    if (mock.startsWith("force:")) {
        force = "force";
        mock = mock.substring("force:".length());
    } else if (mock.startsWith("fail:")) {
        force = "fail";
        mock = mock.substring("fail:".length());
    } else {
        force = "fail";
    }
    String[] tokens = new String[2];
    tokens[0] = force;
    tokens[1] = mock;
    return tokens;
}
 
Example 2
Source File: Overrides.java    From dubbox with Apache License 2.0 6 votes vote down vote up
private String[] parseMock(String mock) {
    mock = URL.decode(mock);
    String force;
    if (mock.startsWith("force:")) {
        force = "force";
        mock = mock.substring("force:".length());
    } else if (mock.startsWith("fail:")) {
        force = "fail";
        mock = mock.substring("fail:".length());
    } else {
        force = "fail";
    }
    String[] tokens = new String[2];
    tokens[0] = force;
    tokens[1] = mock;
    return tokens;
}
 
Example 3
Source File: Overrides.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
private String[] parseMock(String mock) {
    mock = URL.decode(mock);
    String force;
    if (mock.startsWith("force:")) {
        force = "force";
        mock = mock.substring("force:".length());
    } else if (mock.startsWith("fail:")) {
        force = "fail";
        mock = mock.substring("fail:".length());
    } else {
        force = "fail";
    }
    String[] tokens = new String[2];
    tokens[0] = force;
    tokens[1] = mock;
    return tokens;
}
 
Example 4
Source File: Overrides.java    From dubbox with Apache License 2.0 6 votes vote down vote up
private String[] parseMock(String mock) {
    mock = URL.decode(mock);
    String force;
    if (mock.startsWith("force:")) {
        force = "force";
        mock = mock.substring("force:".length());
    } else if (mock.startsWith("fail:")) {
        force = "fail";
        mock = mock.substring("fail:".length());
    } else {
        force = "fail";
    }
    String[] tokens = new String[2];
    tokens[0] = force;
    tokens[1] = mock;
    return tokens;
}
 
Example 5
Source File: Overrides.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void show(Long id, Map<String, Object> context) {
    Override override = overrideService.findById(id);
    
    Map<String, String> parameters = parseQueryString(override.getParams());

    if(parameters.get(DEFAULT_MOCK_JSON_KEY) != null) {
        String mock = URL.decode(parameters.get(DEFAULT_MOCK_JSON_KEY));
        String[] tokens = parseMock(mock);
        context.put(FORM_DEFAULT_MOCK_METHOD_FORCE, tokens[0]);
        context.put(FORM_DEFAULT_MOCK_METHOD_JSON, tokens[1]);
        parameters.remove(DEFAULT_MOCK_JSON_KEY);
    }
    
    Map<String, String> method2Force = new LinkedHashMap<String, String>();
    Map<String, String> method2Json = new LinkedHashMap<String, String>();
    
    for (Iterator<Map.Entry<String, String>> iterator = parameters.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<String, String> e =  iterator.next();
        String key = e.getKey();
        
        if(key.endsWith(MOCK_JSON_KEY_POSTFIX)) {
            String m = key.substring(0, key.length() - MOCK_JSON_KEY_POSTFIX.length());
            parseMock(m, e.getValue(), method2Force, method2Json);
            iterator.remove();
        }
    }
    
    context.put("methodForces", method2Force);
    context.put("methodJsons", method2Json);
    context.put("parameters", parameters);
    context.put("override", override);
}
 
Example 6
Source File: Overrides.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public void show(Long id, Map<String, Object> context) {
    Override override = overrideService.findById(id);
    
    Map<String, String> parameters = parseQueryString(override.getParams());

    if(parameters.get(DEFAULT_MOCK_JSON_KEY) != null) {
        String mock = URL.decode(parameters.get(DEFAULT_MOCK_JSON_KEY));
        String[] tokens = parseMock(mock);
        context.put(FORM_DEFAULT_MOCK_METHOD_FORCE, tokens[0]);
        context.put(FORM_DEFAULT_MOCK_METHOD_JSON, tokens[1]);
        parameters.remove(DEFAULT_MOCK_JSON_KEY);
    }
    
    Map<String, String> method2Force = new LinkedHashMap<String, String>();
    Map<String, String> method2Json = new LinkedHashMap<String, String>();
    
    for (Iterator<Map.Entry<String, String>> iterator = parameters.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<String, String> e =  iterator.next();
        String key = e.getKey();
        
        if(key.endsWith(MOCK_JSON_KEY_POSTFIX)) {
            String m = key.substring(0, key.length() - MOCK_JSON_KEY_POSTFIX.length());
            parseMock(m, e.getValue(), method2Force, method2Json);
            iterator.remove();
        }
    }
    
    context.put("methodForces", method2Force);
    context.put("methodJsons", method2Json);
    context.put("parameters", parameters);
    context.put("override", override);
}
 
Example 7
Source File: ZookeeperRegistry.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
private List<URL> toUrlsWithoutEmpty(URL consumer, List<String> providers) {
	List<URL> urls = new ArrayList<URL>();
    if (providers != null && providers.size() > 0) {
        for (String provider : providers) {
            provider = URL.decode(provider);
            if (provider.contains("://")) {
                URL url = URL.valueOf(provider);
                if (UrlUtils.isMatch(consumer, url)) {
                    urls.add(url);
                }
            }
        }
    }
    return urls;
}
 
Example 8
Source File: Overrides.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public void show(Long id, Map<String, Object> context) {
    Override override = overrideService.findById(id);
    
    Map<String, String> parameters = parseQueryString(override.getParams());

    if(parameters.get(DEFAULT_MOCK_JSON_KEY) != null) {
        String mock = URL.decode(parameters.get(DEFAULT_MOCK_JSON_KEY));
        String[] tokens = parseMock(mock);
        context.put(FORM_DEFAULT_MOCK_METHOD_FORCE, tokens[0]);
        context.put(FORM_DEFAULT_MOCK_METHOD_JSON, tokens[1]);
        parameters.remove(DEFAULT_MOCK_JSON_KEY);
    }
    
    Map<String, String> method2Force = new LinkedHashMap<String, String>();
    Map<String, String> method2Json = new LinkedHashMap<String, String>();
    
    for (Iterator<Map.Entry<String, String>> iterator = parameters.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<String, String> e =  iterator.next();
        String key = e.getKey();
        
        if(key.endsWith(MOCK_JSON_KEY_POSTFIX)) {
            String m = key.substring(0, key.length() - MOCK_JSON_KEY_POSTFIX.length());
            parseMock(m, e.getValue(), method2Force, method2Json);
            iterator.remove();
        }
    }
    
    context.put("methodForces", method2Force);
    context.put("methodJsons", method2Json);
    context.put("parameters", parameters);
    context.put("override", override);
}
 
Example 9
Source File: ZookeeperRegistry.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private List<URL> toUrlsWithoutEmpty(URL consumer, List<String> providers) {
	List<URL> urls = new ArrayList<URL>();
    if (providers != null && providers.size() > 0) {
        for (String provider : providers) {
            provider = URL.decode(provider);
            if (provider.contains("://")) {
                URL url = URL.valueOf(provider);
                if (UrlUtils.isMatch(consumer, url)) {
                    urls.add(url);
                }
            }
        }
    }
    return urls;
}
 
Example 10
Source File: ConsulRegistry.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private void doNotify(URL url, Collection<NotifyListener> listeners) {
	List<URL> result = new ArrayList<URL>();
	String consumerService = url.getServiceInterface();
	try {
		Response<List<HealthService>> response = this.consulClient.getHealthServices(consumerService, true, QueryParams.DEFAULT);
		List<HealthService> healthServices = (List<HealthService>) response.getValue();
		Iterator<HealthService> iterator = healthServices.iterator();
		while (iterator.hasNext()) {
			HealthService healthService = (HealthService) iterator.next();
			HealthService.Service service = healthService.getService();
			List<URL> urls = new ArrayList<URL>();
			String serviceURL = URL.decode(service.getAddress());
			URL u = URL.valueOf(serviceURL);
			if (UrlUtils.isMatch(url, u)) {
				urls.add(u);
			}
			result.addAll(urls);
			if (logger.isInfoEnabled()) {
				logger.info("Consul notify:  = " + urls);
			}
		}
		if (result == null || result.size() == 0) {
			return;
		}
		for (NotifyListener listener : listeners) {
			notify(url, listener, result);
		}
	} catch (OperationException e) {
		throw e;
	}
}
 
Example 11
Source File: ZookeeperRegistry.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private List<URL> toUrlsWithoutEmpty(URL consumer, List<String> providers) {
	List<URL> urls = new ArrayList<URL>();
    if (providers != null && providers.size() > 0) {
        for (String provider : providers) {
            provider = URL.decode(provider);
            if (provider.contains("://")) {
                URL url = URL.valueOf(provider);
                if (UrlUtils.isMatch(consumer, url)) {
                    urls.add(url);
                }
            }
        }
    }
    return urls;
}
 
Example 12
Source File: ZookeeperRegistry.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
private List<URL> toUrlsWithoutEmpty(URL consumer, List<String> providers) {
    List<URL> urls = new ArrayList<URL>();
    if (providers != null && !providers.isEmpty()) {
        for (String provider : providers) {
            provider = URL.decode(provider);
            if (provider.contains("://")) {
                URL url = URL.valueOf(provider);
                if (UrlUtils.isMatch(consumer, url)) {
                    urls.add(url);
                }
            }
        }
    }
    return urls;
}
 
Example 13
Source File: Tool.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public static String decodeUrl(String url) {
    return URL.decode(url);
}
 
Example 14
Source File: Tool.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public static String decodeUrl(String url) {
    return URL.decode(url);
}
 
Example 15
Source File: Tool.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public static String decodeUrl(String url) {
    return URL.decode(url);
}
 
Example 16
Source File: Tool.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public static String decodeUrl(String url) {
    return URL.decode(url);
}
 
Example 17
Source File: Tool.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public static String decodeUrl(String url) {
    return URL.decode(url);
}
 
Example 18
Source File: Tool.java    From open-capacity-platform with Apache License 2.0 4 votes vote down vote up
public static String decodeUrl(String url) {
    return URL.decode(url);
}
 
Example 19
Source File: Tool.java    From dubbo3 with Apache License 2.0 4 votes vote down vote up
public static String decodeUrl(String url) {
    return URL.decode(url);
}
 
Example 20
Source File: Tool.java    From dubbo3 with Apache License 2.0 4 votes vote down vote up
public static String decodeUrl(String url) {
    return URL.decode(url);
}