本文整理汇总了Java中com.alibaba.dubbo.registry.integration.RegistryDirectory.setRegistry方法的典型用法代码示例。如果您正苦于以下问题:Java RegistryDirectory.setRegistry方法的具体用法?Java RegistryDirectory.setRegistry怎么用?Java RegistryDirectory.setRegistry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.dubbo.registry.integration.RegistryDirectory
的用法示例。
在下文中一共展示了RegistryDirectory.setRegistry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testDestroy_WithDestroyRegistry
import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入方法依赖的package包/类
@Test
public void testDestroy_WithDestroyRegistry() {
RegistryDirectory registryDirectory = getRegistryDirectory();
CountDownLatch latch = new CountDownLatch(1);
registryDirectory.setRegistry(new MockRegistry(latch));
registryDirectory.subscribe(URL.valueOf("consumer://" + NetUtils.getLocalHost() + "/DemoService?category=providers"));
registryDirectory.destroy();
Assert.assertEquals(0, latch.getCount());
}
示例3: testDestroy_WithDestroyRegistry_WithError
import com.alibaba.dubbo.registry.integration.RegistryDirectory; //导入方法依赖的package包/类
@Test
public void testDestroy_WithDestroyRegistry_WithError() {
RegistryDirectory registryDirectory = getRegistryDirectory();
registryDirectory.setRegistry(new MockRegistry(true));
registryDirectory.destroy();
}