本文整理汇总了Java中com.alibaba.dubbo.common.URL.toServiceString方法的典型用法代码示例。如果您正苦于以下问题:Java URL.toServiceString方法的具体用法?Java URL.toServiceString怎么用?Java URL.toServiceString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.dubbo.common.URL
的用法示例。
在下文中一共展示了URL.toServiceString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRegistry
import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public Registry getRegistry(URL url) {
url = url.setPath(RegistryService.class.getName())
.addParameter(Constants.INTERFACE_KEY, RegistryService.class.getName())
.removeParameters(Constants.EXPORT_KEY, Constants.REFER_KEY);
String key = url.toServiceString();
// 锁定注册中心获取过程,保证注册中心单一实例
LOCK.lock();
try {
Registry registry = REGISTRIES.get(key);
if (registry != null) {
return registry;
}
registry = createRegistry(url);
if (registry == null) {
throw new IllegalStateException("Can not create registry " + url);
}
REGISTRIES.put(key, registry);
return registry;
} finally {
// 释放锁
LOCK.unlock();
}
}
示例2: getMonitor
import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public Monitor getMonitor(URL url) {
url = url.setPath(MonitorService.class.getName()).addParameter(Constants.INTERFACE_KEY, MonitorService.class.getName());
String key = url.toServiceString();
LOCK.lock();
try {
Monitor monitor = MONITORS.get(key);
if (monitor != null) {
return monitor;
}
monitor = createMonitor(url);
if (monitor == null) {
throw new IllegalStateException("Can not create monitor " + url);
}
MONITORS.put(key, monitor);
return monitor;
} finally {
// 释放锁
LOCK.unlock();
}
}
示例3: getRegistry
import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public Registry getRegistry(URL url) {
url = url.setPath(RegistryService.class.getName())
.addParameter(Constants.INTERFACE_KEY, RegistryService.class.getName())
.removeParameters(Constants.EXPORT_KEY, Constants.REFER_KEY);
String key = url.toServiceString();
// 锁定注册中心获取过程,保证注册中心单一实例
LOCK.lock();
try {
Registry registry = REGISTRIES.get(key);
if (registry != null) {
return registry;
}
registry = createRegistry(url);
if (registry == null) {
throw new IllegalStateException("Can not create registry " + url);
}
REGISTRIES.put(key, registry);
return registry;
} finally {
// 释放锁
LOCK.unlock();
}
}