Java Code Examples for com.alibaba.dubbo.registry.integration.RegistryDirectory#setRegistry()
The following examples show how to use
com.alibaba.dubbo.registry.integration.RegistryDirectory#setRegistry() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DubboRegistryFactory.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
@Override 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; }
Example 2
Source File: DubboRegistryFactory.java From dubbox with Apache License 2.0 | 6 votes |
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; }
Example 3
Source File: DubboRegistryFactory.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
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; }
Example 4
Source File: DubboRegistryFactory.java From dubbox with Apache License 2.0 | 6 votes |
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; }
Example 5
Source File: DubboRegistryFactory.java From dubbox with Apache License 2.0 | 6 votes |
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; }
Example 6
Source File: RegistryDirectoryTest.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@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()); }
Example 7
Source File: RegistryDirectoryTest.java From dubbox with Apache License 2.0 | 5 votes |
@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()); }
Example 8
Source File: RegistryDirectoryTest.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
@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()); }
Example 9
Source File: RegistryDirectoryTest.java From dubbox with Apache License 2.0 | 5 votes |
@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()); }
Example 10
Source File: RegistryDirectoryTest.java From dubbox with Apache License 2.0 | 5 votes |
@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()); }
Example 11
Source File: RegistryDirectoryTest.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
@Test public void testDestroy_WithDestroyRegistry_WithError() { RegistryDirectory registryDirectory = getRegistryDirectory(); registryDirectory.setRegistry(new MockRegistry(true)); registryDirectory.destroy(); }
Example 12
Source File: RegistryDirectoryTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testDestroy_WithDestroyRegistry_WithError() { RegistryDirectory registryDirectory = getRegistryDirectory(); registryDirectory.setRegistry(new MockRegistry(true)); registryDirectory.destroy(); }
Example 13
Source File: RegistryDirectoryTest.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
@Test public void testDestroy_WithDestroyRegistry_WithError() { RegistryDirectory registryDirectory = getRegistryDirectory(); registryDirectory.setRegistry(new MockRegistry(true)); registryDirectory.destroy(); }
Example 14
Source File: RegistryDirectoryTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testDestroy_WithDestroyRegistry_WithError() { RegistryDirectory registryDirectory = getRegistryDirectory(); registryDirectory.setRegistry(new MockRegistry(true)); registryDirectory.destroy(); }
Example 15
Source File: RegistryDirectoryTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testDestroy_WithDestroyRegistry_WithError() { RegistryDirectory registryDirectory = getRegistryDirectory(); registryDirectory.setRegistry(new MockRegistry(true)); registryDirectory.destroy(); }