Search in sources :

Example 1 with RegistryConfig

use of org.apache.dubbo.config.RegistryConfig in project incubator-dubbo-spring-boot-project by apache.

the class RelaxedDubboConfigBinderTest method testBinder.

@Test
public void testBinder() {
    ApplicationConfig applicationConfig = new ApplicationConfig();
    Map<String, Object> properties = getSubProperties(environment.getPropertySources(), "dubbo.application");
    dubboConfigBinder.bind(properties, true, true, applicationConfig);
    Assert.assertEquals("hello", applicationConfig.getName());
    Assert.assertEquals("world", applicationConfig.getOwner());
    RegistryConfig registryConfig = new RegistryConfig();
    properties = getSubProperties(environment.getPropertySources(), "dubbo.registry");
    dubboConfigBinder.bind(properties, true, true, registryConfig);
    Assert.assertEquals("10.20.153.17", registryConfig.getAddress());
    ProtocolConfig protocolConfig = new ProtocolConfig();
    properties = getSubProperties(environment.getPropertySources(), "dubbo.protocol");
    dubboConfigBinder.bind(properties, true, true, protocolConfig);
    Assert.assertEquals(Integer.valueOf(20881), protocolConfig.getPort());
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) ProtocolConfig(org.apache.dubbo.config.ProtocolConfig) Test(org.junit.Test)

Example 2 with RegistryConfig

use of org.apache.dubbo.config.RegistryConfig in project incubator-dubbo-ops by apache.

the class ApiDocsDubboGenericUtil method getRegistryConfig.

/**
 * Get registry information.
 *
 * @param address Address of Registration Center
 * @return org.apache.dubbo.config.RegistryConfig
 */
private static RegistryConfig getRegistryConfig(String address) {
    RegistryConfig registryConfig = registryConfigCache.get(address);
    if (null == registryConfig) {
        registryConfig = new RegistryConfig();
        registryConfig.setAddress(address);
        registryConfig.setRegister(false);
        registryConfigCache.put(address, registryConfig);
    }
    return registryConfig;
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig)

Example 3 with RegistryConfig

use of org.apache.dubbo.config.RegistryConfig in project incubator-dubbo-ops by apache.

the class GenericServiceImpl method init.

@PostConstruct
public void init() {
    RegistryConfig registryConfig = buildRegistryConfig(registry);
    applicationConfig = new ApplicationConfig();
    applicationConfig.setName("dubbo-admin");
    applicationConfig.setRegistry(registryConfig);
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) PostConstruct(javax.annotation.PostConstruct)

Example 4 with RegistryConfig

use of org.apache.dubbo.config.RegistryConfig in project incubator-dubbo-ops by apache.

the class GenericServiceImpl method buildRegistryConfig.

private RegistryConfig buildRegistryConfig(Registry registry) {
    URL fromUrl = registry.getUrl();
    RegistryConfig config = new RegistryConfig();
    config.setGroup(fromUrl.getParameter("group"));
    URL address = URL.valueOf(fromUrl.getProtocol() + "://" + fromUrl.getAddress());
    if (fromUrl.hasParameter(Constants.NAMESPACE_KEY)) {
        address = address.addParameter(Constants.NAMESPACE_KEY, fromUrl.getParameter(Constants.NAMESPACE_KEY));
    }
    config.setAddress(address.toString());
    return config;
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) URL(org.apache.dubbo.common.URL)

Example 5 with RegistryConfig

use of org.apache.dubbo.config.RegistryConfig in project pinpoint by naver.

the class DubboConsumerPluginTestController method sayHi.

@RequestMapping(value = "/sayHi", method = RequestMethod.GET)
@ResponseBody
public String sayHi() {
    ReferenceConfig<GreetingsService> reference = new ReferenceConfig<>();
    reference.setInterface(GreetingsService.class);
    reference.setGeneric("true");
    DubboBootstrap bootstrap = DubboBootstrap.getInstance();
    bootstrap.application(new ApplicationConfig("dubbo-demo-api-consumer")).registry(new RegistryConfig("zookeeper://" + ZOOKEEPER_HOST + ":2181")).reference(reference).start();
    GreetingsService demoService = ReferenceConfigCache.getCache().get(reference);
    String message = demoService.sayHi("dubbo");
    return message;
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) ReferenceConfig(org.apache.dubbo.config.ReferenceConfig) GreetingsService(com.pinpoint.test.plugin.api.GreetingsService) DubboBootstrap(org.apache.dubbo.config.bootstrap.DubboBootstrap) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

RegistryConfig (org.apache.dubbo.config.RegistryConfig)68 ApplicationConfig (org.apache.dubbo.config.ApplicationConfig)42 Test (org.junit.jupiter.api.Test)34 ProtocolConfig (org.apache.dubbo.config.ProtocolConfig)29 DubboBootstrap (org.apache.dubbo.config.bootstrap.DubboBootstrap)20 ServiceConfig (org.apache.dubbo.config.ServiceConfig)19 ReferenceConfig (org.apache.dubbo.config.ReferenceConfig)16 DemoService (org.apache.dubbo.config.spring.api.DemoService)13 GenericService (org.apache.dubbo.rpc.service.GenericService)8 ArrayList (java.util.ArrayList)7 URL (org.apache.dubbo.common.URL)7 DemoServiceImpl (org.apache.dubbo.config.spring.impl.DemoServiceImpl)7 ConsumerConfig (org.apache.dubbo.config.ConsumerConfig)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 ModuleConfig (org.apache.dubbo.config.ModuleConfig)4 MonitorConfig (org.apache.dubbo.config.MonitorConfig)4 ProviderConfig (org.apache.dubbo.config.ProviderConfig)4 Bean (org.springframework.context.annotation.Bean)4 List (java.util.List)3 MethodConfig (org.apache.dubbo.config.MethodConfig)3