Search in sources :

Example 1 with ProtocolConfig

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();
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) Arrays(java.util.Arrays) UserServiceImpl(org.apache.dubbo.config.bootstrap.rest.UserServiceImpl) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) RegistryConfig(org.apache.dubbo.config.RegistryConfig) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) ServiceConfig(org.apache.dubbo.config.ServiceConfig) MetadataReportConfig(org.apache.dubbo.config.MetadataReportConfig) UserService(org.apache.dubbo.config.bootstrap.rest.UserService) ServiceConfig(org.apache.dubbo.config.ServiceConfig) UserService(org.apache.dubbo.config.bootstrap.rest.UserService) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) UserServiceImpl(org.apache.dubbo.config.bootstrap.rest.UserServiceImpl) MetadataReportConfig(org.apache.dubbo.config.MetadataReportConfig) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig)

Example 2 with ProtocolConfig

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();
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) ServiceConfig(org.apache.dubbo.config.ServiceConfig) UserService(org.apache.dubbo.config.bootstrap.rest.UserService) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) UserServiceImpl(org.apache.dubbo.config.bootstrap.rest.UserServiceImpl) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig)

Example 3 with ProtocolConfig

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());
}
Also used : ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) Test(org.junit.jupiter.api.Test)

Example 4 with ProtocolConfig

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);
}
Also used : AbstractServiceConfig(org.apache.dubbo.config.AbstractServiceConfig) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) Test(org.junit.jupiter.api.Test)

Example 5 with ProtocolConfig

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());
}
Also used : ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) Test(org.junit.jupiter.api.Test)

Aggregations

ProtocolConfig (org.apache.dubbo.config.ProtocolConfig)49 Test (org.junit.jupiter.api.Test)30 RegistryConfig (org.apache.dubbo.config.RegistryConfig)27 ApplicationConfig (org.apache.dubbo.config.ApplicationConfig)25 ServiceConfig (org.apache.dubbo.config.ServiceConfig)14 DubboBootstrap (org.apache.dubbo.config.bootstrap.DubboBootstrap)11 ReferenceConfig (org.apache.dubbo.config.ReferenceConfig)8 DemoService (org.apache.dubbo.config.spring.api.DemoService)8 DemoServiceImpl (org.apache.dubbo.config.spring.impl.DemoServiceImpl)7 ArrayList (java.util.ArrayList)6 ProviderConfig (org.apache.dubbo.config.ProviderConfig)6 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)6 GenericService (org.apache.dubbo.rpc.service.GenericService)5 URL (org.apache.dubbo.common.URL)4 Bean (org.springframework.context.annotation.Bean)4 List (java.util.List)3 Map (java.util.Map)3 ConsumerConfig (org.apache.dubbo.config.ConsumerConfig)3 ConfigTest (org.apache.dubbo.config.spring.ConfigTest)3 JavaBeanDescriptor (org.apache.dubbo.common.beanutil.JavaBeanDescriptor)2