本文整理汇总了Java中com.alibaba.dubbo.registry.integration.RegistryDirectory.setProtocol方法的典型用法代码示例。如果您正苦于以下问题:Java RegistryDirectory.setProtocol方法的具体用法?Java RegistryDirectory.setProtocol怎么用?Java RegistryDirectory.setProtocol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.dubbo.registry.integration.RegistryDirectory
的用法示例。
在下文中一共展示了RegistryDirectory.setProtocol方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRegistry
import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入方法依赖的package包/类
public Registry createRegistry(URL url) {
url = getRegistryURL(url);
List<URL> urls = new ArrayList<URL>();
urls.add(url.removeParameter(Constants.BACKUP_KEY));
String backup = url.getParameter(Constants.BACKUP_KEY);
if (backup != null && backup.length() > 0) {
String[] addresses = Constants.COMMA_SPLIT_PATTERN.split(backup);
for (String address : addresses) {
urls.add(url.setAddress(address));
}
}
RegistryDirectory<RegistryService> directory = new RegistryDirectory<RegistryService>(RegistryService.class, url.addParameter(Constants.INTERFACE_KEY, RegistryService.class.getName()).addParameterAndEncoded(Constants.REFER_KEY, url.toParameterString()));
Invoker<RegistryService> registryInvoker = cluster.join(directory);
RegistryService registryService = proxyFactory.getProxy(registryInvoker);
DubboRegistry registry = new DubboRegistry(registryInvoker, registryService);
directory.setRegistry(registry);
directory.setProtocol(protocol);
directory.notify(urls);
directory.subscribe(new URL(Constants.CONSUMER_PROTOCOL, NetUtils.getLocalHost(), 0, RegistryService.class.getName(), url.getParameters()));
return registry;
}
示例2: getRegistryDirectory
import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入方法依赖的package包/类
private RegistryDirectory getRegistryDirectory(URL url) {
RegistryDirectory registryDirectory = new RegistryDirectory(URL.class, url);
registryDirectory.setProtocol(protocol);
// asert empty
List invokers = registryDirectory.list(invocation);
Assert.assertEquals(0, invokers.size());
Assert.assertEquals(false, registryDirectory.isAvailable());
return registryDirectory;
}