Java Code Examples for com.alibaba.dubbo.config.ReferenceConfig#destroy()
The following examples show how to use
com.alibaba.dubbo.config.ReferenceConfig#destroy() .
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: AnnotationBean.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
@Override public void destroy() { // This will only be called for singleton scope bean, and expected to be called by spring shutdown hook when BeanFactory/ApplicationContext destroys. // We will guarantee dubbo related resources being released with dubbo shutdown hook. // for (ServiceConfig<?> serviceConfig : serviceConfigs) { // try { // serviceConfig.unexport(); // } catch (Throwable e) { // logger.error(e.getMessage(), e); // } // } for (ReferenceConfig<?> referenceConfig : referenceConfigs.values()) { try { referenceConfig.destroy(); } catch (Throwable e) { logger.error(e.getMessage(), e); } } }
Example 2
Source File: ConfigTest.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Test public void testReferGenericExport() throws Exception { ApplicationConfig ac = new ApplicationConfig("test-refer-generic-export"); RegistryConfig rc = new RegistryConfig(); rc.setAddress(RegistryConfig.NO_AVAILABLE); ServiceConfig<GenericService> sc = new ServiceConfig<GenericService>(); sc.setApplication(ac); sc.setRegistry(rc); sc.setInterface(DemoService.class.getName()); sc.setRef(new GenericService() { public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException { return null; } }); ReferenceConfig<DemoService> ref = new ReferenceConfig<DemoService>(); ref.setApplication(ac); ref.setRegistry(rc); ref.setInterface(DemoService.class.getName()); try { sc.export(); ref.get(); Assert.fail(); } catch (Exception e) { e.printStackTrace(); } finally { sc.unexport(); ref.destroy(); } }
Example 3
Source File: Dubbo26ITest.java From java-specialagent with Apache License 2.0 | 5 votes |
public static void main(final String[] args) throws Exception { final CountDownLatch latch = TestUtil.initExpectedSpanLatch(2); final String linkLocalIp = "127.0.0.1"; final ServiceConfig<GreeterService> service = getService(); service.export(); final ReferenceConfig<GreeterService> client = getClient(linkLocalIp, service.getProtocol().getPort()); client.get().sayHello("jorge"); TestUtil.checkSpan(latch, new ComponentSpanCount("java-dubbo", 2)); client.destroy(); service.unexport(); }
Example 4
Source File: ConfigTest.java From dubbo3 with Apache License 2.0 | 5 votes |
@Test public void testReferGenericExport() throws Exception { ApplicationConfig ac = new ApplicationConfig("test-refer-generic-export"); RegistryConfig rc = new RegistryConfig(); rc.setAddress(RegistryConfig.NO_AVAILABLE); ServiceConfig<GenericService> sc = new ServiceConfig<GenericService>(); sc.setApplication(ac); sc.setRegistry(rc); sc.setInterface(DemoService.class.getName()); sc.setRef(new GenericService() { public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException { return null; } }); ReferenceConfig<DemoService> ref = new ReferenceConfig<DemoService>(); ref.setApplication(ac); ref.setRegistry(rc); ref.setInterface(DemoService.class.getName()); try { sc.export(); ref.get(); Assert.fail(); } catch (Exception e) { e.printStackTrace(); } finally { sc.unexport(); ref.destroy(); } }
Example 5
Source File: ConfigTest.java From dubbox with Apache License 2.0 | 5 votes |
@Test public void testReferGenericExport() throws Exception { ApplicationConfig ac = new ApplicationConfig("test-refer-generic-export"); RegistryConfig rc = new RegistryConfig(); rc.setAddress(RegistryConfig.NO_AVAILABLE); ServiceConfig<GenericService> sc = new ServiceConfig<GenericService>(); sc.setApplication(ac); sc.setRegistry(rc); sc.setInterface(DemoService.class.getName()); sc.setRef(new GenericService() { public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException { return null; } }); ReferenceConfig<DemoService> ref = new ReferenceConfig<DemoService>(); ref.setApplication(ac); ref.setRegistry(rc); ref.setInterface(DemoService.class.getName()); try { sc.export(); ref.get(); Assert.fail(); } catch (Exception e) { e.printStackTrace(); } finally { sc.unexport(); ref.destroy(); } }
Example 6
Source File: ConfigTest.java From dubbox with Apache License 2.0 | 5 votes |
@Test public void testReferGenericExport() throws Exception { ApplicationConfig ac = new ApplicationConfig("test-refer-generic-export"); RegistryConfig rc = new RegistryConfig(); rc.setAddress(RegistryConfig.NO_AVAILABLE); ServiceConfig<GenericService> sc = new ServiceConfig<GenericService>(); sc.setApplication(ac); sc.setRegistry(rc); sc.setInterface(DemoService.class.getName()); sc.setRef(new GenericService() { public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException { return null; } }); ReferenceConfig<DemoService> ref = new ReferenceConfig<DemoService>(); ref.setApplication(ac); ref.setRegistry(rc); ref.setInterface(DemoService.class.getName()); try { sc.export(); ref.get(); Assert.fail(); } catch (Exception e) { e.printStackTrace(); } finally { sc.unexport(); ref.destroy(); } }
Example 7
Source File: ReferenceConfigCache.java From dubbox with Apache License 2.0 | 4 votes |
void destroyKey(String key) { ReferenceConfig<?> config = cache.remove(key); if(config == null) return; config.destroy(); }
Example 8
Source File: ConfigTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testApiOverrideProperties() throws Exception { ApplicationConfig application = new ApplicationConfig(); application.setName("api-override-properties"); RegistryConfig registry = new RegistryConfig(); registry.setAddress("N/A"); ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("dubbo"); protocol.setPort(13123); ServiceConfig<DemoService> service = new ServiceConfig<DemoService>(); service.setInterface(DemoService.class); service.setRef(new DemoServiceImpl()); service.setApplication(application); service.setRegistry(registry); service.setProtocol(protocol); service.export(); try { URL url = service.toUrls().get(0); assertEquals("api-override-properties", url.getParameter("application")); assertEquals("world", url.getParameter("owner")); assertEquals(13123, url.getPort()); ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>(); reference.setApplication(new ApplicationConfig("consumer")); reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE)); reference.setInterface(DemoService.class); reference.setUrl("dubbo://127.0.0.1:13123"); reference.get(); try { url = reference.toUrls().get(0); assertEquals("2000", url.getParameter("timeout")); } finally { reference.destroy(); } } finally { service.unexport(); } }
Example 9
Source File: ConfigTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testAppendFilter() throws Exception { ProviderConfig provider = new ProviderConfig(); provider.setFilter("classloader,monitor"); ServiceConfig<DemoService> service = new ServiceConfig<DemoService>(); service.setFilter("accesslog,trace"); service.setProvider(provider); service.setProtocol(new ProtocolConfig("dubbo", 20880)); service.setApplication(new ApplicationConfig("provider")); service.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE)); service.setInterface(DemoService.class); service.setRef(new DemoServiceImpl()); try { service.export(); List<URL> urls = service.toUrls(); assertNotNull(urls); assertEquals(1, urls.size()); assertEquals("classloader,monitor,accesslog,trace", urls.get(0).getParameter("service.filter")); ConsumerConfig consumer = new ConsumerConfig(); consumer.setFilter("classloader,monitor"); ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>(); reference.setFilter("accesslog,trace"); reference.setConsumer(consumer); reference.setApplication(new ApplicationConfig("consumer")); reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE)); reference.setInterface(DemoService.class); reference.setUrl("dubbo://" + NetUtils.getLocalHost() + ":20880?" + DemoService.class.getName() + "?check=false"); try { reference.get(); urls = reference.toUrls(); assertNotNull(urls); assertEquals(1, urls.size()); assertEquals("classloader,monitor,accesslog,trace", urls.get(0).getParameter("reference.filter")); } finally { reference.destroy(); } } finally { service.unexport(); } }
Example 10
Source File: ReferenceConfigCache.java From dubbo3 with Apache License 2.0 | 4 votes |
void destroyKey(String key) { ReferenceConfig<?> config = cache.remove(key); if (config == null) return; config.destroy(); }
Example 11
Source File: ConfigTest.java From dubbo3 with Apache License 2.0 | 4 votes |
@Test public void testApiOverrideProperties() throws Exception { ApplicationConfig application = new ApplicationConfig(); application.setName("api-override-properties"); RegistryConfig registry = new RegistryConfig(); registry.setAddress("N/A"); ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("dubbo"); protocol.setPort(13123); ServiceConfig<DemoService> service = new ServiceConfig<DemoService>(); service.setInterface(DemoService.class); service.setRef(new DemoServiceImpl()); service.setApplication(application); service.setRegistry(registry); service.setProtocol(protocol); service.export(); try { URL url = service.toUrls().get(0); assertEquals("api-override-properties", url.getParameter("application")); assertEquals("world", url.getParameter("owner")); assertEquals(13123, url.getPort()); ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>(); reference.setApplication(new ApplicationConfig("consumer")); reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE)); reference.setInterface(DemoService.class); reference.setUrl("dubbo://127.0.0.1:13123"); reference.get(); try { url = reference.toUrls().get(0); assertEquals("2000", url.getParameter("timeout")); } finally { reference.destroy(); } } finally { service.unexport(); } }
Example 12
Source File: ReferenceConfigCache.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
void destroyKey(String key) { ReferenceConfig<?> config = cache.remove(key); if(config == null) return; config.destroy(); }
Example 13
Source File: ConfigTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testApiOverrideProperties() throws Exception { ApplicationConfig application = new ApplicationConfig(); application.setName("api-override-properties"); RegistryConfig registry = new RegistryConfig(); registry.setAddress("N/A"); ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("dubbo"); protocol.setPort(13123); ServiceConfig<DemoService> service = new ServiceConfig<DemoService>(); service.setInterface(DemoService.class); service.setRef(new DemoServiceImpl()); service.setApplication(application); service.setRegistry(registry); service.setProtocol(protocol); service.export(); try { URL url = service.toUrls().get(0); assertEquals("api-override-properties", url.getParameter("application")); assertEquals("world", url.getParameter("owner")); assertEquals(13123, url.getPort()); ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>(); reference.setApplication(new ApplicationConfig("consumer")); reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE)); reference.setInterface(DemoService.class); reference.setUrl("dubbo://127.0.0.1:13123"); reference.get(); try { url = reference.toUrls().get(0); assertEquals("2000", url.getParameter("timeout")); } finally { reference.destroy(); } } finally { service.unexport(); } }
Example 14
Source File: ReferenceConfigCache.java From dubbox with Apache License 2.0 | 4 votes |
void destroyKey(String key) { ReferenceConfig<?> config = cache.remove(key); if(config == null) return; config.destroy(); }
Example 15
Source File: ReferenceConfigCache.java From dubbox with Apache License 2.0 | 4 votes |
void destroyKey(String key) { ReferenceConfig<?> config = cache.remove(key); if(config == null) return; config.destroy(); }
Example 16
Source File: ConfigTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testApiOverrideProperties() throws Exception { ApplicationConfig application = new ApplicationConfig(); application.setName("api-override-properties"); RegistryConfig registry = new RegistryConfig(); registry.setAddress("N/A"); ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("dubbo"); protocol.setPort(13123); ServiceConfig<DemoService> service = new ServiceConfig<DemoService>(); service.setInterface(DemoService.class); service.setRef(new DemoServiceImpl()); service.setApplication(application); service.setRegistry(registry); service.setProtocol(protocol); service.export(); try { URL url = service.toUrls().get(0); assertEquals("api-override-properties", url.getParameter("application")); assertEquals("world", url.getParameter("owner")); assertEquals(13123, url.getPort()); ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>(); reference.setApplication(new ApplicationConfig("consumer")); reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE)); reference.setInterface(DemoService.class); reference.setUrl("dubbo://127.0.0.1:13123"); reference.get(); try { url = reference.toUrls().get(0); assertEquals("2000", url.getParameter("timeout")); } finally { reference.destroy(); } } finally { service.unexport(); } }
Example 17
Source File: ConfigTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testAppendFilter() throws Exception { ProviderConfig provider = new ProviderConfig(); provider.setFilter("classloader,monitor"); ServiceConfig<DemoService> service = new ServiceConfig<DemoService>(); service.setFilter("accesslog,trace"); service.setProvider(provider); service.setProtocol(new ProtocolConfig("dubbo", 20880)); service.setApplication(new ApplicationConfig("provider")); service.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE)); service.setInterface(DemoService.class); service.setRef(new DemoServiceImpl()); try { service.export(); List<URL> urls = service.toUrls(); assertNotNull(urls); assertEquals(1, urls.size()); assertEquals("classloader,monitor,accesslog,trace", urls.get(0).getParameter("service.filter")); ConsumerConfig consumer = new ConsumerConfig(); consumer.setFilter("classloader,monitor"); ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>(); reference.setFilter("accesslog,trace"); reference.setConsumer(consumer); reference.setApplication(new ApplicationConfig("consumer")); reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE)); reference.setInterface(DemoService.class); reference.setUrl("dubbo://" + NetUtils.getLocalHost() + ":20880?" + DemoService.class.getName() + "?check=false"); try { reference.get(); urls = reference.toUrls(); assertNotNull(urls); assertEquals(1, urls.size()); assertEquals("classloader,monitor,accesslog,trace", urls.get(0).getParameter("reference.filter")); } finally { reference.destroy(); } } finally { service.unexport(); } }
Example 18
Source File: ReferenceConfigCache.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
void destroyKey(String key) { ReferenceConfig<?> config = cache.remove(key); if (config == null) return; config.destroy(); }
Example 19
Source File: ConfigTest.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
@Test public void testApiOverrideProperties() throws Exception { ApplicationConfig application = new ApplicationConfig(); application.setName("api-override-properties"); RegistryConfig registry = new RegistryConfig(); registry.setAddress("N/A"); ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("dubbo"); protocol.setPort(13123); ServiceConfig<DemoService> service = new ServiceConfig<DemoService>(); service.setInterface(DemoService.class); service.setRef(new DemoServiceImpl()); service.setApplication(application); service.setRegistry(registry); service.setProtocol(protocol); service.export(); try { URL url = service.toUrls().get(0); assertEquals("api-override-properties", url.getParameter("application")); assertEquals("world", url.getParameter("owner")); assertEquals(13123, url.getPort()); ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>(); reference.setApplication(new ApplicationConfig("consumer")); reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE)); reference.setInterface(DemoService.class); reference.setUrl("dubbo://127.0.0.1:13123"); reference.get(); try { url = reference.toUrls().get(0); assertEquals("2000", url.getParameter("timeout")); } finally { reference.destroy(); } } finally { service.unexport(); } }
Example 20
Source File: ConfigTest.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
@Test public void testAppendFilter() throws Exception { ProviderConfig provider = new ProviderConfig(); provider.setFilter("classloader,monitor"); ServiceConfig<DemoService> service = new ServiceConfig<DemoService>(); service.setFilter("accesslog,trace"); service.setProvider(provider); service.setProtocol(new ProtocolConfig("dubbo", 20880)); service.setApplication(new ApplicationConfig("provider")); service.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE)); service.setInterface(DemoService.class); service.setRef(new DemoServiceImpl()); try { service.export(); List<URL> urls = service.toUrls(); assertNotNull(urls); assertEquals(1, urls.size()); assertEquals("classloader,monitor,accesslog,trace", urls.get(0).getParameter("service.filter")); ConsumerConfig consumer = new ConsumerConfig(); consumer.setFilter("classloader,monitor"); ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>(); reference.setFilter("accesslog,trace"); reference.setConsumer(consumer); reference.setApplication(new ApplicationConfig("consumer")); reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE)); reference.setInterface(DemoService.class); reference.setUrl("dubbo://" + NetUtils.getLocalHost() + ":20880?" + DemoService.class.getName() + "?check=false"); try { reference.get(); urls = reference.toUrls(); assertNotNull(urls); assertEquals(1, urls.size()); assertEquals("classloader,monitor,accesslog,trace", urls.get(0).getParameter("reference.filter")); } finally { reference.destroy(); } } finally { service.unexport(); } }