use of org.apache.dubbo.config.ProtocolConfig in project dubbo by alibaba.
the class DubboServiceProviderBootstrap method multipleRegistries.
private static void multipleRegistries() {
ProtocolConfig restProtocol = new ProtocolConfig();
restProtocol.setName("rest");
restProtocol.setId("rest");
restProtocol.setPort(-1);
RegistryConfig interfaceRegistry = new RegistryConfig();
interfaceRegistry.setId("interfaceRegistry");
interfaceRegistry.setAddress("zookeeper://127.0.0.1:2181");
RegistryConfig serviceRegistry = new RegistryConfig();
serviceRegistry.setId("serviceRegistry");
serviceRegistry.setAddress("zookeeper://127.0.0.1:2181?registry-type=service");
ServiceConfig<EchoService> echoService = new ServiceConfig<>();
echoService.setInterface(EchoService.class.getName());
echoService.setRef(new EchoServiceImpl());
// echoService.setRegistries(Arrays.asList(interfaceRegistry, serviceRegistry));
ServiceConfig<UserService> userService = new ServiceConfig<>();
userService.setInterface(UserService.class.getName());
userService.setRef(new UserServiceImpl());
userService.setProtocol(restProtocol);
// userService.setRegistries(Arrays.asList(interfaceRegistry, serviceRegistry));
ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-provider-demo");
applicationConfig.setMetadataType("remote");
DubboBootstrap.getInstance().application(applicationConfig).registries(Arrays.asList(interfaceRegistry, serviceRegistry)).protocol(builder -> builder.port(-1).name("dubbo")).metadataReport(new MetadataReportConfig("zookeeper://127.0.0.1:2181")).service(echoService).service(userService).start().await();
}
use of org.apache.dubbo.config.ProtocolConfig in project dubbo by alibaba.
the class EtcdDubboServiceProviderBootstrap method multipleRegistries.
private static void multipleRegistries() {
ProtocolConfig restProtocol = new ProtocolConfig();
restProtocol.setName("rest");
restProtocol.setId("rest");
restProtocol.setPort(-1);
RegistryConfig interfaceRegistry = new RegistryConfig();
interfaceRegistry.setId("interfaceRegistry");
interfaceRegistry.setAddress("etcd3://127.0.0.1:2379");
RegistryConfig serviceRegistry = new RegistryConfig();
serviceRegistry.setId("serviceRegistry");
serviceRegistry.setAddress("etcd3://127.0.0.1:2379?registry-type=service");
ServiceConfig<EchoService> echoService = new ServiceConfig<>();
echoService.setInterface(EchoService.class.getName());
echoService.setRef(new EchoServiceImpl());
// echoService.setRegistries(Arrays.asList(interfaceRegistry, serviceRegistry));
ServiceConfig<UserService> userService = new ServiceConfig<>();
userService.setInterface(UserService.class.getName());
userService.setRef(new UserServiceImpl());
userService.setProtocol(restProtocol);
// userService.setRegistries(Arrays.asList(interfaceRegistry, serviceRegistry));
ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-provider-demo");
// applicationConfig.setMetadataType("remote");
DubboBootstrap.getInstance().application(applicationConfig).registries(Arrays.asList(interfaceRegistry, serviceRegistry)).protocol(builder -> builder.port(-1).name("dubbo")).service(echoService).service(userService).start().await();
}
use of org.apache.dubbo.config.ProtocolConfig in project dubbo by alibaba.
the class AbstractServiceBuilderTest method addProtocols.
@Test
void addProtocols() {
ProtocolConfig protocol = new ProtocolConfig();
ServiceBuilder builder = new ServiceBuilder();
Assertions.assertNull(builder.build().getProtocols());
builder.addProtocols(Collections.singletonList(protocol));
Assertions.assertNotNull(builder.build().getProtocols());
Assertions.assertEquals(1, builder.build().getProtocols().size());
}
use of org.apache.dubbo.config.ProtocolConfig in project dubbo by alibaba.
the class AbstractServiceBuilderTest method build.
@Test
void build() {
ProtocolConfig protocol = new ProtocolConfig();
ServiceBuilder builder = new ServiceBuilder();
builder.version("version").group("group").deprecated(true).delay(1000).export(false).weight(1).document("document").dynamic(true).token("token").accesslog("accesslog").addProtocol(protocol).protocolIds("protocolIds").tag("tag").executes(100).register(false).warmup(200).serialization("serialization").id("id").prefix("prefix");
ServiceConfig config = builder.build();
ServiceConfig config2 = builder.build();
Assertions.assertEquals("id", config.getId());
Assertions.assertEquals("prefix", config.getPrefix());
Assertions.assertEquals("version", config.getVersion());
Assertions.assertEquals("group", config.getGroup());
Assertions.assertEquals("document", config.getDocument());
Assertions.assertEquals("token", config.getToken());
Assertions.assertEquals("accesslog", config.getAccesslog());
Assertions.assertEquals("protocolIds", config.getProtocolIds());
Assertions.assertEquals("tag", config.getTag());
Assertions.assertEquals("serialization", config.getSerialization());
Assertions.assertTrue(config.isDeprecated());
Assertions.assertFalse(config.getExport());
Assertions.assertTrue(config.isDynamic());
Assertions.assertFalse(config.isRegister());
Assertions.assertEquals(1000, config.getDelay());
Assertions.assertEquals(1, config.getWeight());
Assertions.assertEquals(100, config.getExecutes());
Assertions.assertEquals(200, config.getWarmup());
Assertions.assertNotSame(config, config2);
}
use of org.apache.dubbo.config.ProtocolConfig in project dubbo by alibaba.
the class AbstractServiceBuilderTest method addProtocol.
@Test
void addProtocol() {
ProtocolConfig protocol = new ProtocolConfig();
ServiceBuilder builder = new ServiceBuilder();
Assertions.assertNull(builder.build().getProtocols());
builder.addProtocol(protocol);
Assertions.assertNotNull(builder.build().getProtocols());
Assertions.assertEquals(1, builder.build().getProtocols().size());
Assertions.assertEquals(protocol, builder.build().getProtocol());
}
Aggregations