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


Java URL.hasParameter方法代码示例

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


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

示例1: handle

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public Page handle(URL url) {
    String provider = url.getParameterAndDecoded("provider");
    if (provider == null || provider.length() == 0) {
        throw new IllegalArgumentException("Please input provider parameter.");
    }
    URL providerUrl = URL.valueOf(provider);
    RegistryContainer.getInstance().getRegistry().unregister(providerUrl);
    String parameter;
    if (url.hasParameter("service")) {
        parameter = "service=" + url.getParameter("service");
    } else if (url.hasParameter("host")) {
        parameter = "host=" + url.getParameter("host");
    } else if (url.hasParameter("application")) {
        parameter = "application=" + url.getParameter("application");
    } else {
        parameter = "service=" + providerUrl.getServiceInterface();
    }
    return new Page("<script type=\"text/javascript\">window.location.href=\"providers.html?" + parameter + "\";</script>");
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:20,代码来源:UnregisterPageHandler.java

示例2: handle

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public Page handle(URL url) {
    String consumer = url.getParameterAndDecoded("consumer");
    if (consumer == null || consumer.length() == 0) {
        throw new IllegalArgumentException("Please input consumer parameter.");
    }
    URL consumerUrl = URL.valueOf(consumer);
    RegistryContainer.getInstance().getRegistry().unsubscribe(consumerUrl, NotifyListenerAdapter.NOTIFY_LISTENER);
    String parameter;
    if (url.hasParameter("service")) {
        parameter = "service=" + url.getParameter("service");
    } else if (url.hasParameter("host")) {
        parameter = "host=" + url.getParameter("host");
    } else if (url.hasParameter("application")) {
        parameter = "application=" + url.getParameter("application");
    } else {
        parameter = "service=" + consumerUrl.getServiceInterface();
    }
    return new Page("<script type=\"text/javascript\">window.location.href=\"consumers.html?" + parameter + "\";</script>");
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:20,代码来源:UnsubscribePageHandler.java

示例3: RpcInvocation

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public RpcInvocation(Invocation invocation, Invoker<?> invoker) {
    this(invocation.getMethodName(), invocation.getParameterTypes(), 
            invocation.getArguments(), new HashMap<String, String>(invocation.getAttachments()),
            invocation.getInvoker());
    if (invoker != null) {
        URL url = invoker.getUrl();
        setAttachment(Constants.PATH_KEY, url.getPath());
        if (url.hasParameter(Constants.INTERFACE_KEY)) {
            setAttachment(Constants.INTERFACE_KEY, url.getParameter(Constants.INTERFACE_KEY));
        }
        if (url.hasParameter(Constants.GROUP_KEY)) {
            setAttachment(Constants.GROUP_KEY, url.getParameter(Constants.GROUP_KEY));
        }
        if (url.hasParameter(Constants.VERSION_KEY)) {
            setAttachment(Constants.VERSION_KEY, url.getParameter(Constants.VERSION_KEY, "0.0.0"));
        }
        if (url.hasParameter(Constants.TIMEOUT_KEY)) {
            setAttachment(Constants.TIMEOUT_KEY, url.getParameter(Constants.TIMEOUT_KEY));
        }
        if (url.hasParameter(Constants.TOKEN_KEY)) {
            setAttachment(Constants.TOKEN_KEY, url.getParameter(Constants.TOKEN_KEY));
        }
        if (url.hasParameter(Constants.APPLICATION_KEY)) {
            setAttachment(Constants.APPLICATION_KEY, url.getParameter(Constants.APPLICATION_KEY));
        }
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:28,代码来源:RpcInvocation.java

示例4: RpcInvocation

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public RpcInvocation(Invocation invocation, Invoker<?> invoker) {
    this(invocation.getMethodName(), invocation.getParameterTypes(), 
            invocation.getArguments(), new HashMap<String, String>(invocation.getAttachments()),
            invocation.getInvoker(),invocation.getInvoker().getUrl().getParameter(Constants.METHOD_HYSTRIX_KEY,Boolean.FALSE));
    if (invoker != null) {
        URL url = invoker.getUrl();
        setAttachment(Constants.PATH_KEY, url.getPath());
        if (url.hasParameter(Constants.INTERFACE_KEY)) {
            setAttachment(Constants.INTERFACE_KEY, url.getParameter(Constants.INTERFACE_KEY));
        }
        if (url.hasParameter(Constants.GROUP_KEY)) {
            setAttachment(Constants.GROUP_KEY, url.getParameter(Constants.GROUP_KEY));
        }
        if (url.hasParameter(Constants.VERSION_KEY)) {
            setAttachment(Constants.VERSION_KEY, url.getParameter(Constants.VERSION_KEY, "0.0.0"));
        }
        if (url.hasParameter(Constants.TIMEOUT_KEY)) {
            setAttachment(Constants.TIMEOUT_KEY, url.getParameter(Constants.TIMEOUT_KEY));
        }
        if (url.hasParameter(Constants.TOKEN_KEY)) {
            setAttachment(Constants.TOKEN_KEY, url.getParameter(Constants.TOKEN_KEY));
        }
        if (url.hasParameter(Constants.APPLICATION_KEY)) {
            setAttachment(Constants.APPLICATION_KEY, url.getParameter(Constants.APPLICATION_KEY));
        }
        if (url.hasParameter(Constants.METHOD_HYSTRIX_KEY)) {
            setAttachment(Constants.METHOD_HYSTRIX_KEY, url.getParameter(Constants.METHOD_HYSTRIX_KEY));
        }
    }
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:31,代码来源:RpcInvocation.java

示例5: toInvokers

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
/**
 * 将urls转成invokers,如果url已经被refer过,不再重新引用。
 * 
 * @param urls
 * @param overrides
 * @param query
 * @return invokers
 */
private Map<String, Invoker<T>> toInvokers(List<URL> urls) {
    Map<String, Invoker<T>> newUrlInvokerMap = new HashMap<String, Invoker<T>>();
    if(urls == null || urls.size() == 0){
        return newUrlInvokerMap;
    }
    Set<String> keys = new HashSet<String>();
    String queryProtocols = this.queryMap.get(Constants.PROTOCOL_KEY);
    for (URL providerUrl : urls) {
    	//如果reference端配置了protocol,则只选择匹配的protocol
    	if (queryProtocols != null && queryProtocols.length() >0) {
    		boolean accept = false;
    		String[] acceptProtocols = queryProtocols.split(",");
    		for (String acceptProtocol : acceptProtocols) {
    			if (providerUrl.getProtocol().equals(acceptProtocol)) {
    				accept = true;
    				break;
    			}
    		}
    		if (!accept) {
    			continue;
    		}
    	}
        if (Constants.EMPTY_PROTOCOL.equals(providerUrl.getProtocol())) {
            continue;
        }
        if (! ExtensionLoader.getExtensionLoader(Protocol.class).hasExtension(providerUrl.getProtocol())) {
            logger.error(new IllegalStateException("Unsupported protocol " + providerUrl.getProtocol() + " in notified url: " + providerUrl + " from registry " + getUrl().getAddress() + " to consumer " + NetUtils.getLocalHost() 
                    + ", supported protocol: "+ExtensionLoader.getExtensionLoader(Protocol.class).getSupportedExtensions()));
            continue;
        }
        URL url = mergeUrl(providerUrl);
        
        String key = url.toFullString(); // URL参数是排序的
        if (keys.contains(key)) { // 重复URL
            continue;
        }
        keys.add(key);
        // 缓存key为没有合并消费端参数的URL,不管消费端如何合并参数,如果服务端URL发生变化,则重新refer
        Map<String, Invoker<T>> localUrlInvokerMap = this.urlInvokerMap; // local reference
        Invoker<T> invoker = localUrlInvokerMap == null ? null : localUrlInvokerMap.get(key);
        if (invoker == null) { // 缓存中没有,重新refer
            try {
            	boolean enabled = true;
            	if (url.hasParameter(Constants.DISABLED_KEY)) {
            		enabled = ! url.getParameter(Constants.DISABLED_KEY, false);
            	} else {
            		enabled = url.getParameter(Constants.ENABLED_KEY, true);
            	}
            	if (enabled) {
            		invoker = new InvokerDelegete<T>(protocol.refer(serviceType, url), url, providerUrl);
            	}
            } catch (Throwable t) {
                logger.error("Failed to refer invoker for interface:"+serviceType+",url:("+url+")" + t.getMessage(), t);
            }
            if (invoker != null) { // 将新的引用放入缓存
                newUrlInvokerMap.put(key, invoker);
            }
        }else {
            newUrlInvokerMap.put(key, invoker);
        }
    }
    keys.clear();
    return newUrlInvokerMap;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:73,代码来源:RegistryDirectory.java

示例6: toInvokers

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
/**
 * 将urls转成invokers,如果url已经被refer过,不再重新引用。
 *
 * @param urls
 * @param overrides
 * @param query
 * @return invokers
 */
private Map<String, Invoker<T>> toInvokers(List<URL> urls) {
    Map<String, Invoker<T>> newUrlInvokerMap = new HashMap<String, Invoker<T>>();
    if (urls == null || urls.size() == 0) {
        return newUrlInvokerMap;
    }
    Set<String> keys = new HashSet<String>();
    String queryProtocols = this.queryMap.get(Constants.PROTOCOL_KEY);
    for (URL providerUrl : urls) {
        //如果reference端配置了protocol,则只选择匹配的protocol
        if (queryProtocols != null && queryProtocols.length() > 0) {
            boolean accept = false;
            String[] acceptProtocols = queryProtocols.split(",");
            for (String acceptProtocol : acceptProtocols) {
                if (providerUrl.getProtocol().equals(acceptProtocol)) {
                    accept = true;
                    break;
                }
            }
            if (!accept) {
                continue;
            }
        }
        if (Constants.EMPTY_PROTOCOL.equals(providerUrl.getProtocol())) {
            continue;
        }
        if (!ExtensionLoader.getExtensionLoader(Protocol.class).hasExtension(providerUrl.getProtocol())) {
            logger.error(new IllegalStateException("Unsupported protocol " + providerUrl.getProtocol() + " in notified url: " + providerUrl + " from registry " + getUrl().getAddress() + " to consumer " + NetUtils.getLocalHost()
                    + ", supported protocol: " + ExtensionLoader.getExtensionLoader(Protocol.class).getSupportedExtensions()));
            continue;
        }
        URL url = mergeUrl(providerUrl);

        String key = url.toFullString(); // URL参数是排序的
        if (keys.contains(key)) { // 重复URL
            continue;
        }
        keys.add(key);
        // 缓存key为没有合并消费端参数的URL,不管消费端如何合并参数,如果服务端URL发生变化,则重新refer
        Map<String, Invoker<T>> localUrlInvokerMap = this.urlInvokerMap; // local reference
        Invoker<T> invoker = localUrlInvokerMap == null ? null : localUrlInvokerMap.get(key);
        if (invoker == null) { // 缓存中没有,重新refer
            try {
                boolean enabled = true;
                if (url.hasParameter(Constants.DISABLED_KEY)) {
                    enabled = !url.getParameter(Constants.DISABLED_KEY, false);
                } else {
                    enabled = url.getParameter(Constants.ENABLED_KEY, true);
                }
                if (enabled) {
                    invoker = new InvokerDelegete<T>(protocol.refer(serviceType, url), url, providerUrl);
                }
            } catch (Throwable t) {
                logger.error("Failed to refer invoker for interface:" + serviceType + ",url:(" + url + ")" + t.getMessage(), t);
            }
            if (invoker != null) { // 将新的引用放入缓存
                newUrlInvokerMap.put(key, invoker);
            }
        } else {
            newUrlInvokerMap.put(key, invoker);
        }
    }
    keys.clear();
    return newUrlInvokerMap;
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:73,代码来源:RegistryDirectory.java


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