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;
}
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();
}
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"));
}
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");
}
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");
}
}
Aggregations