Java Code Examples for com.alibaba.dubbo.config.ProtocolConfig#setName()
The following examples show how to use
com.alibaba.dubbo.config.ProtocolConfig#setName() .
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: DubboProviderBootstrap.java From sofa-rpc with Apache License 2.0 | 6 votes |
private void copyServerFields(ServerConfig serverConfig, ProtocolConfig protocolConfig) { protocolConfig.setId(serverConfig.getId()); protocolConfig.setName(serverConfig.getProtocol()); protocolConfig.setHost(serverConfig.getHost()); protocolConfig.setPort(serverConfig.getPort()); protocolConfig.setAccepts(serverConfig.getAccepts()); protocolConfig.setSerialization(serverConfig.getSerialization()); if (!StringUtils.CONTEXT_SEP.equals(serverConfig.getContextPath())) { protocolConfig.setContextpath(serverConfig.getContextPath()); } protocolConfig.setIothreads(serverConfig.getIoThreads()); protocolConfig.setThreadpool(serverConfig.getThreadPoolType()); protocolConfig.setThreads(serverConfig.getMaxThreads()); protocolConfig.setPayload(serverConfig.getPayload()); protocolConfig.setQueues(serverConfig.getQueues()); protocolConfig.setParameters(serverConfig.getParameters()); }
Example 2
Source File: ConfigTest.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Test public void testProtocolRandomPort() throws Exception { ServiceConfig<DemoService> demoService = null; ServiceConfig<HelloService> helloService = null; ApplicationConfig application = new ApplicationConfig(); application.setName("test-protocol-random-port"); RegistryConfig registry = new RegistryConfig(); registry.setAddress("N/A"); ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("dubbo"); protocol.setPort(-1); demoService = new ServiceConfig<DemoService>(); demoService.setInterface(DemoService.class); demoService.setRef(new DemoServiceImpl()); demoService.setApplication(application); demoService.setRegistry(registry); demoService.setProtocol(protocol); helloService = new ServiceConfig<HelloService>(); helloService.setInterface(HelloService.class); helloService.setRef(new HelloServiceImpl()); helloService.setApplication(application); helloService.setRegistry(registry); helloService.setProtocol(protocol); try { demoService.export(); helloService.export(); Assert.assertEquals(demoService.getExportedUrls().get(0).getPort(), helloService.getExportedUrls().get(0).getPort()); } finally { unexportService(demoService); unexportService(helloService); } }
Example 3
Source File: ConfigTest.java From dubbox with Apache License 2.0 | 5 votes |
@Test public void testProtocolRandomPort() throws Exception { ServiceConfig<DemoService> demoService = null; ServiceConfig<HelloService> helloService = null; ApplicationConfig application = new ApplicationConfig(); application.setName("test-protocol-random-port"); RegistryConfig registry = new RegistryConfig(); registry.setAddress("N/A"); ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("dubbo"); protocol.setPort(-1); demoService = new ServiceConfig<DemoService>(); demoService.setInterface(DemoService.class); demoService.setRef(new DemoServiceImpl()); demoService.setApplication(application); demoService.setRegistry(registry); demoService.setProtocol(protocol); helloService = new ServiceConfig<HelloService>(); helloService.setInterface(HelloService.class); helloService.setRef(new HelloServiceImpl()); helloService.setApplication(application); helloService.setRegistry(registry); helloService.setProtocol(protocol); try { demoService.export(); helloService.export(); Assert.assertEquals(demoService.getExportedUrls().get(0).getPort(), helloService.getExportedUrls().get(0).getPort()); } finally { unexportService(demoService); unexportService(helloService); } }
Example 4
Source File: DubboConfig.java From swagger-dubbo with Apache License 2.0 | 5 votes |
@Bean public ProtocolConfig protocolConfig() { ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("dubbo"); protocol.setPort(29880); return protocol; }
Example 5
Source File: DubboConfig.java From dubbox-zookeeper-demo with Apache License 2.0 | 5 votes |
@Bean public ProtocolConfig protocalConfig(){ ProtocolConfig protocolConfig = new ProtocolConfig(); protocolConfig.setName(getProtocolName()); protocolConfig.setPort(getProtocalPort()); return protocolConfig; }
Example 6
Source File: ConfigTest.java From dubbo3 with Apache License 2.0 | 5 votes |
@Test public void testProtocolRandomPort() throws Exception { ServiceConfig<DemoService> demoService = null; ServiceConfig<HelloService> helloService = null; ApplicationConfig application = new ApplicationConfig(); application.setName("test-protocol-random-port"); RegistryConfig registry = new RegistryConfig(); registry.setAddress("N/A"); ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("dubbo"); protocol.setPort(-1); demoService = new ServiceConfig<DemoService>(); demoService.setInterface(DemoService.class); demoService.setRef(new DemoServiceImpl()); demoService.setApplication(application); demoService.setRegistry(registry); demoService.setProtocol(protocol); helloService = new ServiceConfig<HelloService>(); helloService.setInterface(HelloService.class); helloService.setRef(new HelloServiceImpl()); helloService.setApplication(application); helloService.setRegistry(registry); helloService.setProtocol(protocol); try { demoService.export(); helloService.export(); Assert.assertEquals(demoService.getExportedUrls().get(0).getPort(), helloService.getExportedUrls().get(0).getPort()); } finally { unexportService(demoService); unexportService(helloService); } }
Example 7
Source File: ConfigTest.java From dubbox with Apache License 2.0 | 5 votes |
@Test public void testProtocolRandomPort() throws Exception { ServiceConfig<DemoService> demoService = null; ServiceConfig<HelloService> helloService = null; ApplicationConfig application = new ApplicationConfig(); application.setName("test-protocol-random-port"); RegistryConfig registry = new RegistryConfig(); registry.setAddress("N/A"); ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("dubbo"); protocol.setPort(-1); demoService = new ServiceConfig<DemoService>(); demoService.setInterface(DemoService.class); demoService.setRef(new DemoServiceImpl()); demoService.setApplication(application); demoService.setRegistry(registry); demoService.setProtocol(protocol); helloService = new ServiceConfig<HelloService>(); helloService.setInterface(HelloService.class); helloService.setRef(new HelloServiceImpl()); helloService.setApplication(application); helloService.setRegistry(registry); helloService.setProtocol(protocol); try { demoService.export(); helloService.export(); Assert.assertEquals(demoService.getExportedUrls().get(0).getPort(), helloService.getExportedUrls().get(0).getPort()); } finally { unexportService(demoService); unexportService(helloService); } }
Example 8
Source File: DubboConfiguration.java From cicada with MIT License | 5 votes |
@Bean public ProtocolConfig dubboProtocol() { final ProtocolConfig protocol = new ProtocolConfig(); protocol.setName(dubboProperty.getProtocolName()); protocol.setPort(dubboProperty.getProtocolPort()); return protocol; }
Example 9
Source File: ConfigTest.java From dubbo3 with Apache License 2.0 | 4 votes |
@Test public void testSystemPropertyOverrideProperties() throws Exception { String portString = System.getProperty( "dubbo.protocol.port"); System.clearProperty("dubbo.protocol.port"); try { int port = 1234; System.setProperty("dubbo.protocol.port", String.valueOf(port)); ApplicationConfig application = new ApplicationConfig(); application.setName("aaa"); RegistryConfig registry = new RegistryConfig(); registry.setAddress("N/A"); ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("rmi"); 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); // from api assertEquals("aaa", url.getParameter("application")); // from dubbo.properties assertEquals("world", url.getParameter("owner")); // from system property assertEquals(1234, url.getPort()); } finally { service.unexport(); } } finally { if (portString != null) { System.setProperty("dubbo.protocol.port", portString); } } }
Example 10
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 11
Source File: ConfigTest.java From dubbo3 with Apache License 2.0 | 4 votes |
@Test public void testSystemPropertyOverrideApi() throws Exception { System.setProperty("dubbo.application.name", "sysover"); System.setProperty("dubbo.application.owner", "sysowner"); System.setProperty("dubbo.registry.address", "N/A"); System.setProperty("dubbo.protocol.name", "dubbo"); System.setProperty("dubbo.protocol.port", "20834"); try { ApplicationConfig application = new ApplicationConfig(); application.setName("aaa"); RegistryConfig registry = new RegistryConfig(); registry.setAddress("127.0.0.1"); ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("rmi"); protocol.setPort(1099); 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("sysover", url.getParameter("application")); assertEquals("sysowner", url.getParameter("owner")); assertEquals("dubbo", url.getProtocol()); assertEquals(20834, url.getPort()); } finally { service.unexport(); } } finally { System.setProperty("dubbo.application.name", ""); System.setProperty("dubbo.application.owner", ""); System.setProperty("dubbo.registry.address", ""); System.setProperty("dubbo.protocol.name", ""); System.setProperty("dubbo.protocol.port", ""); } }
Example 12
Source File: ConfigTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testSystemPropertyOverrideProperties() throws Exception { String portString = System.getProperty( "dubbo.protocol.port"); System.clearProperty("dubbo.protocol.port"); try { int port = 1234; System.setProperty("dubbo.protocol.port", String.valueOf(port)); ApplicationConfig application = new ApplicationConfig(); application.setName("aaa"); RegistryConfig registry = new RegistryConfig(); registry.setAddress("N/A"); ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("rmi"); 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); // from api assertEquals("aaa", url.getParameter("application")); // from dubbo.properties assertEquals("world", url.getParameter("owner")); // from system property assertEquals(1234, url.getPort()); } finally { service.unexport(); } } finally { if (portString != null) { System.setProperty("dubbo.protocol.port", portString); } } }
Example 13
Source File: ConfigTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testSystemPropertyOverrideApi() throws Exception { System.setProperty("dubbo.application.name", "sysover"); System.setProperty("dubbo.application.owner", "sysowner"); System.setProperty("dubbo.registry.address", "N/A"); System.setProperty("dubbo.protocol.name", "dubbo"); System.setProperty("dubbo.protocol.port", "20834"); try { ApplicationConfig application = new ApplicationConfig(); application.setName("aaa"); RegistryConfig registry = new RegistryConfig(); registry.setAddress("127.0.0.1"); ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("rmi"); protocol.setPort(1099); 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("sysover", url.getParameter("application")); assertEquals("sysowner", url.getParameter("owner")); assertEquals("dubbo", url.getProtocol()); assertEquals(20834, url.getPort()); } finally { service.unexport(); } } finally { System.setProperty("dubbo.application.name", ""); System.setProperty("dubbo.application.owner", ""); System.setProperty("dubbo.registry.address", ""); System.setProperty("dubbo.protocol.name", ""); System.setProperty("dubbo.protocol.port", ""); } }
Example 14
Source File: ConfigTest.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
@Test public void testSystemPropertyOverrideApi() throws Exception { System.setProperty("dubbo.application.name", "sysover"); System.setProperty("dubbo.application.owner", "sysowner"); System.setProperty("dubbo.registry.address", "N/A"); System.setProperty("dubbo.protocol.name", "dubbo"); System.setProperty("dubbo.protocol.port", "20834"); try { ApplicationConfig application = new ApplicationConfig(); application.setName("aaa"); RegistryConfig registry = new RegistryConfig(); registry.setAddress("127.0.0.1"); ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("rmi"); protocol.setPort(1099); 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("sysover", url.getParameter("application")); assertEquals("sysowner", url.getParameter("owner")); assertEquals("dubbo", url.getProtocol()); assertEquals(20834, url.getPort()); } finally { service.unexport(); } } finally { System.setProperty("dubbo.application.name", ""); System.setProperty("dubbo.application.owner", ""); System.setProperty("dubbo.registry.address", ""); System.setProperty("dubbo.protocol.name", ""); System.setProperty("dubbo.protocol.port", ""); } }
Example 15
Source File: ConfigTest.java From dubbox-hystrix 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 16
Source File: ConfigTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testSystemPropertyOverrideProperties() throws Exception { String portString = System.getProperty( "dubbo.protocol.port"); System.clearProperty("dubbo.protocol.port"); try { int port = 1234; System.setProperty("dubbo.protocol.port", String.valueOf(port)); ApplicationConfig application = new ApplicationConfig(); application.setName("aaa"); RegistryConfig registry = new RegistryConfig(); registry.setAddress("N/A"); ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("rmi"); 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); // from api assertEquals("aaa", url.getParameter("application")); // from dubbo.properties assertEquals("world", url.getParameter("owner")); // from system property assertEquals(1234, url.getPort()); } finally { service.unexport(); } } finally { if (portString != null) { System.setProperty("dubbo.protocol.port", portString); } } }
Example 17
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 18
Source File: ConfigTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testSystemPropertyOverrideApi() throws Exception { System.setProperty("dubbo.application.name", "sysover"); System.setProperty("dubbo.application.owner", "sysowner"); System.setProperty("dubbo.registry.address", "N/A"); System.setProperty("dubbo.protocol.name", "dubbo"); System.setProperty("dubbo.protocol.port", "20834"); try { ApplicationConfig application = new ApplicationConfig(); application.setName("aaa"); RegistryConfig registry = new RegistryConfig(); registry.setAddress("127.0.0.1"); ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("rmi"); protocol.setPort(1099); 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("sysover", url.getParameter("application")); assertEquals("sysowner", url.getParameter("owner")); assertEquals("dubbo", url.getProtocol()); assertEquals(20834, url.getPort()); } finally { service.unexport(); } } finally { System.setProperty("dubbo.application.name", ""); System.setProperty("dubbo.application.owner", ""); System.setProperty("dubbo.registry.address", ""); System.setProperty("dubbo.protocol.name", ""); System.setProperty("dubbo.protocol.port", ""); } }
Example 19
Source File: ConfigTest.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
@Test public void testSystemPropertyOverrideProperties() throws Exception { String portString = System.getProperty("dubbo.protocol.port"); System.clearProperty("dubbo.protocol.port"); try { int port = 1234; System.setProperty("dubbo.protocol.port", String.valueOf(port)); ApplicationConfig application = new ApplicationConfig(); application.setName("aaa"); RegistryConfig registry = new RegistryConfig(); registry.setAddress("N/A"); ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("rmi"); 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); // from api assertEquals("aaa", url.getParameter("application")); // from dubbo.properties assertEquals("world", url.getParameter("owner")); // from system property assertEquals(1234, url.getPort()); } finally { service.unexport(); } } finally { if (portString != null) { System.setProperty("dubbo.protocol.port", portString); } } }
Example 20
Source File: ConfigTest.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
@Test public void testSystemPropertyOverrideApi() throws Exception { System.setProperty("dubbo.application.name", "sysover"); System.setProperty("dubbo.application.owner", "sysowner"); System.setProperty("dubbo.registry.address", "N/A"); System.setProperty("dubbo.protocol.name", "dubbo"); System.setProperty("dubbo.protocol.port", "20834"); try { ApplicationConfig application = new ApplicationConfig(); application.setName("aaa"); RegistryConfig registry = new RegistryConfig(); registry.setAddress("127.0.0.1"); ProtocolConfig protocol = new ProtocolConfig(); protocol.setName("rmi"); protocol.setPort(1099); 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("sysover", url.getParameter("application")); assertEquals("sysowner", url.getParameter("owner")); assertEquals("dubbo", url.getProtocol()); assertEquals(20834, url.getPort()); } finally { service.unexport(); } } finally { System.setProperty("dubbo.application.name", ""); System.setProperty("dubbo.application.owner", ""); System.setProperty("dubbo.registry.address", ""); System.setProperty("dubbo.protocol.name", ""); System.setProperty("dubbo.protocol.port", ""); } }