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


Java URL.getPath方法代码示例

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


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

示例1: getRouter

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public Router getRouter(URL url) {
    try {
        // File URL 转换成 其它Route URL,然后Load
        // file:///d:/path/to/route.js?router=script ==> script:///d:/path/to/route.js?type=js&rule=<file-content>
        String protocol = url.getParameter(Constants.ROUTER_KEY, ScriptRouterFactory.NAME); // 将原类型转为协议
        String type = null; // 使用文件后缀做为类型
        String path = url.getPath();
        if (path != null) {
            int i = path.lastIndexOf('.');
            if (i > 0) {
                type = path.substring(i + 1);
            }
        }
        String rule = IOUtils.read(new FileReader(new File(url.getAbsolutePath())));
        URL script = url.setProtocol(protocol).addParameter(Constants.TYPE_KEY, type).addParameterAndEncoded(Constants.RULE_KEY, rule);
        
        return routerFactory.getRouter(script);
    } catch (IOException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:22,代码来源:FileRouterFactory.java

示例2: FileExchangeGroup

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public FileExchangeGroup(URL url){
    super(url);
    String path = url.getHost() + "/" + url.getPath();
    file = new File(path);
    if (! file.exists()) {
        throw new IllegalStateException("The group file not exists. file: " + path);
    }
    checkModifiedFuture = scheduledExecutorService.scheduleWithFixedDelay(new Runnable() {
        public void run() {
            // 检测文件变更
            try {
                check();
            } catch (Throwable t) { // 防御性容错
                logger.error("Unexpected error occur at reconnect, cause: " + t.getMessage(), t);
            }
        }
    }, 2000, 2000, TimeUnit.MILLISECONDS);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:19,代码来源:FileExchangeGroup.java

示例3: createMonitor

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
@Override
protected Monitor createMonitor(URL url) {
    url = url.setProtocol(url.getParameter(Constants.PROTOCOL_KEY, "dubbo"));
    if (url.getPath() == null || url.getPath().length() == 0) {
        url = url.setPath(MonitorService.class.getName());
    }
    String filter = url.getParameter(Constants.REFERENCE_FILTER_KEY);
    if (filter == null || filter.length() == 0) {
        filter = "";
    } else {
        filter = filter + ",";
    }
    url = url.addParameters(Constants.CLUSTER_KEY, "failsafe", Constants.CHECK_KEY, String.valueOf(false), 
            Constants.REFERENCE_FILTER_KEY, filter + "-monitor");
    Invoker<MonitorService> monitorInvoker = protocol.refer(MonitorService.class, url);
    MonitorService monitorService = proxyFactory.getProxy(monitorInvoker);
    return new DubboMonitor(monitorInvoker, monitorService);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:19,代码来源:DubboMonitorFactroy.java

示例4: getRouter

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public Router getRouter(URL url) {
    try {
        // File URL 转换成 其它Route URL,然后Load
        // file:///d:/path/to/route.js?router=script ==> script:///d:/path/to/route.js?type=js&rule=<file-content>
        String protocol = url.getParameter(Constants.ROUTER_KEY, ScriptRouterFactory.NAME); // 将原类型转为协议
        String type = null; // 使用文件后缀做为类型
        String path = url.getPath();
        if (path != null) {
            int i = path.lastIndexOf('.');
            if (i > 0) {
                type = path.substring(i + 1);
            }
        }
        String rule = IOUtils.read(new FileReader(new File(url.getAbsolutePath())));
        URL script = url.setProtocol(protocol).addParameter(Constants.TYPE_KEY, type).addParameterAndEncoded(Constants.RULE_KEY, rule);

        return routerFactory.getRouter(script);
    } catch (IOException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:22,代码来源:FileRouterFactory.java

示例5: mergeUrl

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
/**
 * 合并url参数 顺序为override > -D >Consumer > Provider
 * @param providerUrl
 * @param overrides
 * @return
 */
private URL mergeUrl(URL providerUrl){
    providerUrl = ClusterUtils.mergeUrl(providerUrl, queryMap); // 合并消费端参数
    
    List<Configurator> localConfigurators = this.configurators; // local reference
    if (localConfigurators != null && localConfigurators.size() > 0) {
        for (Configurator configurator : localConfigurators) {
            providerUrl = configurator.configure(providerUrl);
        }
    }
    
    providerUrl = providerUrl.addParameter(Constants.CHECK_KEY, String.valueOf(false)); // 不检查连接是否成功,总是创建Invoker!
    
    //directoryUrl 与 override 合并是在notify的最后,这里不能够处理
    this.overrideDirectoryUrl = this.overrideDirectoryUrl.addParametersIfAbsent(providerUrl.getParameters()); // 合并提供者参数        
    
    if ((providerUrl.getPath() == null || providerUrl.getPath().length() == 0)
            && "dubbo".equals(providerUrl.getProtocol())) { // 兼容1.0
        //fix by tony.chenl DUBBO-44
        String path = directoryUrl.getParameter(Constants.INTERFACE_KEY);
        if (path != null) {
            int i = path.indexOf('/');
            if (i >= 0) {
                path = path.substring(i + 1);
            }
            i = path.lastIndexOf(':');
            if (i >= 0) {
                path = path.substring(0, i);
            }
            providerUrl = providerUrl.setPath(path);
        }
    }
    return providerUrl;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:40,代码来源:RegistryDirectory.java

示例6: mergeUrl

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
/**
 * 合并url参数 顺序为override > -D >Consumer > Provider
 *
 * @param providerUrl
 * @param overrides
 * @return
 */
private URL mergeUrl(URL providerUrl) {
    providerUrl = ClusterUtils.mergeUrl(providerUrl, queryMap); // 合并消费端参数

    List<Configurator> localConfigurators = this.configurators; // local reference
    if (localConfigurators != null && localConfigurators.size() > 0) {
        for (Configurator configurator : localConfigurators) {
            providerUrl = configurator.configure(providerUrl);
        }
    }

    providerUrl = providerUrl.addParameter(Constants.CHECK_KEY, String.valueOf(false)); // 不检查连接是否成功,总是创建Invoker!

    //directoryUrl 与 override 合并是在notify的最后,这里不能够处理
    this.overrideDirectoryUrl = this.overrideDirectoryUrl.addParametersIfAbsent(providerUrl.getParameters()); // 合并提供者参数        

    if ((providerUrl.getPath() == null || providerUrl.getPath().length() == 0)
            && "dubbo".equals(providerUrl.getProtocol())) { // 兼容1.0
        //fix by tony.chenl DUBBO-44
        String path = directoryUrl.getParameter(Constants.INTERFACE_KEY);
        if (path != null) {
            int i = path.indexOf('/');
            if (i >= 0) {
                path = path.substring(i + 1);
            }
            i = path.lastIndexOf(':');
            if (i >= 0) {
                path = path.substring(0, i);
            }
            providerUrl = providerUrl.setPath(path);
        }
    }
    return providerUrl;
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:41,代码来源:RegistryDirectory.java


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