Search in sources :

Example 6 with ApplicationConfig

use of org.apache.dubbo.config.ApplicationConfig 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)

Example 7 with ApplicationConfig

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

the class DubboProviderApplication method startWithBootstrap.

private static void startWithBootstrap() {
    ServiceConfig<GreetingsServiceImpl> service = new ServiceConfig<>();
    service.setInterface(GreetingsService.class);
    service.setRef(new GreetingsServiceImpl());
    DubboBootstrap bootstrap = DubboBootstrap.getInstance();
    bootstrap.application(new ApplicationConfig("dubbo-demo-api-provider")).registry(new RegistryConfig("zookeeper://" + ZOOKEEPER_HOST + ":2181")).service(service).start().await();
}
Also used : RegistryConfig(org.apache.dubbo.config.RegistryConfig) ServiceConfig(org.apache.dubbo.config.ServiceConfig) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) DubboBootstrap(org.apache.dubbo.config.bootstrap.DubboBootstrap)

Example 8 with ApplicationConfig

use of org.apache.dubbo.config.ApplicationConfig in project dubbo by alibaba.

the class DubboBootstrapTest method testLoadMonitor.

@Test
public void testLoadMonitor() {
    System.setProperty("dubbo.monitor.address", "monitor-addr:12080");
    System.setProperty("dubbo.monitor.protocol", "monitor");
    AbstractInterfaceConfigTest.InterfaceConfig interfaceConfig = new AbstractInterfaceConfigTest.InterfaceConfig();
    interfaceConfig.setApplication(new ApplicationConfig("testLoadMonitor"));
    interfaceConfig.setMonitor(new MonitorConfig());
    URL url = ConfigValidationUtils.loadMonitor(interfaceConfig, new URL("dubbo", "addr1", 9090));
    Assertions.assertEquals("monitor-addr:12080", url.getAddress());
    Assertions.assertEquals(MonitorService.class.getName(), url.getParameter("interface"));
    Assertions.assertNotNull(url.getParameter("dubbo"));
    Assertions.assertNotNull(url.getParameter("pid"));
    Assertions.assertNotNull(url.getParameter("timestamp"));
}
Also used : AbstractInterfaceConfigTest(org.apache.dubbo.config.AbstractInterfaceConfigTest) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) MonitorService(org.apache.dubbo.monitor.MonitorService) URL(org.apache.dubbo.common.URL) MonitorConfig(org.apache.dubbo.config.MonitorConfig) AbstractInterfaceConfigTest(org.apache.dubbo.config.AbstractInterfaceConfigTest) Test(org.junit.jupiter.api.Test)

Example 9 with ApplicationConfig

use of org.apache.dubbo.config.ApplicationConfig in project dubbo by alibaba.

the class DubboBootstrapTest method checkApplication.

@Test
public void checkApplication() {
    System.setProperty("dubbo.application.name", "demo");
    ApplicationConfig applicationConfig = new ApplicationConfig();
    applicationConfig.refresh();
    Assertions.assertEquals("demo", applicationConfig.getName());
    System.clearProperty("dubbo.application.name");
}
Also used : ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) AbstractInterfaceConfigTest(org.apache.dubbo.config.AbstractInterfaceConfigTest) Test(org.junit.jupiter.api.Test)

Example 10 with ApplicationConfig

use of org.apache.dubbo.config.ApplicationConfig in project dubbo by alibaba.

the class DubboBootstrapTest method testLoadRegistries.

@Test
public void testLoadRegistries() {
    try {
        System.setProperty("dubbo.registry.address", "addr1");
        AbstractInterfaceConfigTest.InterfaceConfig interfaceConfig = new AbstractInterfaceConfigTest.InterfaceConfig();
        // FIXME: now we need to check first, then load
        interfaceConfig.setApplication(new ApplicationConfig("testLoadRegistries"));
        interfaceConfig.checkRegistry();
        List<URL> urls = ConfigValidationUtils.loadRegistries(interfaceConfig, true);
        Assertions.assertEquals(1, urls.size());
        URL url = urls.get(0);
        Assertions.assertEquals("registry", url.getProtocol());
        Assertions.assertEquals("addr1:9090", url.getAddress());
        Assertions.assertEquals(RegistryService.class.getName(), url.getPath());
        Assertions.assertTrue(url.getParameters().containsKey("timestamp"));
        Assertions.assertTrue(url.getParameters().containsKey("pid"));
        Assertions.assertTrue(url.getParameters().containsKey("registry"));
        Assertions.assertTrue(url.getParameters().containsKey("dubbo"));
    } finally {
        System.clearProperty("dubbo.registry.address");
    }
}
Also used : AbstractInterfaceConfigTest(org.apache.dubbo.config.AbstractInterfaceConfigTest) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) RegistryService(org.apache.dubbo.registry.RegistryService) URL(org.apache.dubbo.common.URL) AbstractInterfaceConfigTest(org.apache.dubbo.config.AbstractInterfaceConfigTest) Test(org.junit.jupiter.api.Test)

Aggregations

ApplicationConfig (org.apache.dubbo.config.ApplicationConfig)75 RegistryConfig (org.apache.dubbo.config.RegistryConfig)42 Test (org.junit.jupiter.api.Test)32 ProtocolConfig (org.apache.dubbo.config.ProtocolConfig)27 DubboBootstrap (org.apache.dubbo.config.bootstrap.DubboBootstrap)19 ServiceConfig (org.apache.dubbo.config.ServiceConfig)18 ReferenceConfig (org.apache.dubbo.config.ReferenceConfig)16 DemoService (org.apache.dubbo.config.spring.api.DemoService)13 URL (org.apache.dubbo.common.URL)9 GenericService (org.apache.dubbo.rpc.service.GenericService)8 Test (org.junit.Test)8 DemoServiceImpl (org.apache.dubbo.config.spring.impl.DemoServiceImpl)7 ArrayList (java.util.ArrayList)6 MonitorConfig (org.apache.dubbo.config.MonitorConfig)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 AbstractInterfaceConfigTest (org.apache.dubbo.config.AbstractInterfaceConfigTest)4 UserService (org.apache.dubbo.config.bootstrap.rest.UserService)4 MetadataReportConfig (org.apache.dubbo.config.MetadataReportConfig)3 ModuleConfig (org.apache.dubbo.config.ModuleConfig)3 UserServiceImpl (org.apache.dubbo.config.bootstrap.rest.UserServiceImpl)3