org.apache.dubbo.config.RegistryConfig Java Examples

The following examples show how to use org.apache.dubbo.config.RegistryConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DubboConfigsMetadata.java    From dubbo-spring-boot-project with Apache License 2.0 6 votes vote down vote up
public Map<String, Map<String, Map<String, Object>>> configs() {

        Map<String, Map<String, Map<String, Object>>> configsMap = new LinkedHashMap<>();

        addDubboConfigBeans(ApplicationConfig.class, configsMap);
        addDubboConfigBeans(ConsumerConfig.class, configsMap);
        addDubboConfigBeans(MethodConfig.class, configsMap);
        addDubboConfigBeans(ModuleConfig.class, configsMap);
        addDubboConfigBeans(MonitorConfig.class, configsMap);
        addDubboConfigBeans(ProtocolConfig.class, configsMap);
        addDubboConfigBeans(ProviderConfig.class, configsMap);
        addDubboConfigBeans(ReferenceConfig.class, configsMap);
        addDubboConfigBeans(RegistryConfig.class, configsMap);
        addDubboConfigBeans(ServiceConfig.class, configsMap);

        return configsMap;

    }
 
Example #2
Source File: TestServer.java    From brave with Apache License 2.0 6 votes vote down vote up
TestServer(Propagation.Factory propagationFactory, ApplicationConfig application) {
  extractor = propagationFactory.get().extractor(Map::get);
  linkLocalIp = Platform.get().linkLocalIp();
  if (linkLocalIp != null) {
    // avoid dubbo's logic which might pick docker ip
    System.setProperty(CommonConstants.DUBBO_IP_TO_BIND, linkLocalIp);
    System.setProperty(Constants.DUBBO_IP_TO_REGISTRY, linkLocalIp);
  }
  service = new ServiceConfig<>();
  service.setApplication(application);
  service.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
  service.setProtocol(new ProtocolConfig("dubbo", PickUnusedPort.get()));
  service.setInterface(GreeterService.class);
  service.setRef((method, parameterTypes, args) -> {
    requestQueue.add(extractor.extract(RpcContext.getContext().getAttachments()));
    return args[0];
  });
}
 
Example #3
Source File: GenericCallConsumer.java    From dubbo-samples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
        ApplicationConfig applicationConfig = new ApplicationConfig();
        applicationConfig.setName("generic-call-consumer");
        RegistryConfig registryConfig = new RegistryConfig();
        registryConfig.setAddress("zookeeper://127.0.0.1:2181");
        ReferenceConfig<GenericService> referenceConfig = new ReferenceConfig<>();
        referenceConfig.setInterface("org.apache.dubbo.samples.generic.call.api.HelloService");
        applicationConfig.setRegistry(registryConfig);
        referenceConfig.setApplication(applicationConfig);
        referenceConfig.setGeneric(true);
        referenceConfig.setAsync(true);
        referenceConfig.setTimeout(7000);

        genericService = referenceConfig.get();
        invokeSayHello();
        invokeSayHelloAsync();
        invokeAsyncSayHelloAsync();
        invokeAsyncSayHello();
//        invokeSayHelloAsyncComplex();
        asyncInvokeSayHelloAsyncComplex();
//        invokeSayHelloAsyncGenericComplex();
        asyncInvokeSayHelloAsyncGenericComplex();
    }
 
Example #4
Source File: GenericImplProvider.java    From dubbo-samples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    new EmbeddedZooKeeper(2181, false).start();

    ApplicationConfig applicationConfig = new ApplicationConfig();
    applicationConfig.setName("generic-impl-provider");
    RegistryConfig registryConfig = new RegistryConfig();
    registryConfig.setAddress(zookeeperAddress);

    GenericService helloService = new GenericImplOfHelloService();
    ServiceConfig<GenericService> service = new ServiceConfig<>();
    service.setApplication(applicationConfig);
    service.setRegistry(registryConfig);
    service.setInterface("org.apache.dubbo.samples.generic.call.api.HelloService");
    service.setRef(helloService);
    service.setGeneric("true");
    service.export();

    System.out.println("dubbo service started");
    new CountDownLatch(1).await();
}
 
Example #5
Source File: Application.java    From dubbo-samples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    ServiceConfig<UserService> service = new ServiceConfig<>();
    service.setInterface(UserService.class);
    service.setRef(new UserServiceImpl());

    ProtocolConfig protocolConfig = new ProtocolConfig("rest");
    protocolConfig.setPort(8090);

    DubboBootstrap bootstrap = DubboBootstrap.getInstance();
    bootstrap.application(new ApplicationConfig("dubbo-provider-for-sc"))
            .registry(new RegistryConfig("consul://127.0.0.1:8500?registry-type=service"))
            .protocol(protocolConfig)
            .service(service)
            .start()
            .await();
}
 
Example #6
Source File: RelaxedDubboConfigBinderTest.java    From dubbo-spring-boot-project with Apache License 2.0 6 votes vote down vote up
@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());

}
 
Example #7
Source File: BinderDubboConfigBinderTest.java    From dubbo-spring-boot-project with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example #8
Source File: SslBasicConsumer.java    From dubbo-samples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    SslConfig sslConfig = new SslConfig();
    if (args.length > 0) {
        if (args.length != 1 && args.length != 3) {
            System.out.println(
                    "USAGE: BasicConsumer [trustCertCollectionFilePath [certChainFilePath privateKeyFilePath]]\n " +
                            "Specify 'certChainFilePath' and 'privateKeyFilePath' only if you need Mutual TLS.");
            System.exit(0);
        }

        switch (args.length) {
            case 1:
                sslConfig.setClientTrustCertCollectionPath(args[0]);
                break;
            case 3:
                sslConfig.setClientTrustCertCollectionPath(args[0]);
                sslConfig.setClientKeyCertChainPath(args[1]);
                sslConfig.setClientPrivateKeyPath(args[2]);
        }
    }

    DubboBootstrap bootstrap = DubboBootstrap.getInstance()
            .application(new ApplicationConfig("first-dubbo-consumer"))
            .registry(new RegistryConfig("zookeeper://127.0.0.1:2181"))
            .ssl(sslConfig);

    ReferenceConfig<DemoService> reference = new ReferenceConfig<>();
    reference.setInterface(DemoService.class);

    bootstrap.reference(reference);

    bootstrap.start();

    DemoService service = bootstrap.getCache().get(reference);
    String message = service.sayHello("dubbo");
    System.out.println(message);
}
 
Example #9
Source File: ChronusAutoConfiguration.java    From chronus with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnBean({ApplicationConfig.class, RegistryConfig.class})
public ChronusSdkProcessor chronusSdkFacade() {
    ChronusSdkProcessor chronusClientFacade = new AbstractSdkService(){};
    ServiceConfig<ChronusSdkProcessor> serviceConfig = new ServiceConfig<>();
    serviceConfig.setApplication(applicationConfig);
    serviceConfig.setRegistry(registryConfig);
    serviceConfig.setInterface(ChronusSdkProcessor.class);
    serviceConfig.setRef(chronusClientFacade);
    serviceConfig.setPath("/" + applicationConfig.getName() + "/" + ChronusSdkProcessor.class.getName());
    //serviceConfig.setGroup(applicationConfig.getName());
    serviceConfig.export();
    return chronusClientFacade;
}
 
Example #10
Source File: Consumer.java    From rpcx-benchmark with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    ReferenceConfig<DemoService> reference = new ReferenceConfig<>();
    reference.setApplication(new ApplicationConfig("dubbo-demo-api-consumer"));
    String zk = "zookeeper://127.0.0.1:2181";
    if (args.length > 2) {
        zk = args[2];
    }
    reference.setRegistry(new RegistryConfig(zk));
    reference.setInterface(DemoService.class);
    reference.setTimeout(10000);
    DemoService service = reference.get();

    DemoAction demoAction = new DemoAction();
    demoAction.setDemoService(service);

    if (args.length > 0) {
        demoAction.threads = Integer.parseInt(args[0]);
    }
    if (args.length > 1) {
        demoAction.count = Integer.parseInt(args[1]);
    }

    demoAction.warmup();

    demoAction.start();

}
 
Example #11
Source File: Provider.java    From rpcx-benchmark with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    ServiceConfig<DemoServiceImpl> service = new ServiceConfig<>();
    service.setApplication(new ApplicationConfig("dubbo-demo-api-provider"));
    String zk = "zookeeper://127.0.0.1:2181";
    if (args.length > 0) {
        zk = args[0];
    }
    service.setRegistry(new RegistryConfig(zk));
    service.setInterface(DemoService.class);
    service.setRef(new DemoServiceImpl());
    service.export();

    Thread.sleep(24 * 3600 * 1000);

}
 
Example #12
Source File: SslBasicConsumer.java    From dubbo-samples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    SslConfig sslConfig = new SslConfig();
    if (args.length > 0) {
        if (args.length != 1 && args.length != 3) {
            System.out.println(
                    "USAGE: BasicConsumer [trustCertCollectionFilePath [certChainFilePath privateKeyFilePath]]\n " +
                            "Specify 'certChainFilePath' and 'privateKeyFilePath' only if you need Mutual TLS.");
            System.exit(0);
        }

        switch (args.length) {
            case 1:
                sslConfig.setClientTrustCertCollectionPath(args[0]);
                break;
            case 3:
                sslConfig.setClientTrustCertCollectionPath(args[0]);
                sslConfig.setClientKeyCertChainPath(args[1]);
                sslConfig.setClientPrivateKeyPath(args[2]);
        }
    }

    DubboBootstrap bootstrap = DubboBootstrap.getInstance()
            .application(new ApplicationConfig("first-dubbo-consumer"))
            .registry(new RegistryConfig("zookeeper://127.0.0.1:2181"))
            .ssl(sslConfig);

    ReferenceConfig<IGreeter> reference = new ReferenceConfig<>();
    reference.setInterface(IGreeter.class);

    bootstrap.reference(reference);

    bootstrap.start();

    IGreeter service = bootstrap.getCache().get(reference);
    HelloReply helloReply = service.sayHello(HelloRequest.newBuilder().setName("dubbo").build());
    System.out.println(helloReply.getMessage());
}
 
Example #13
Source File: HelloServiceIT.java    From dubbo-samples with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUp() throws Exception {
    ApplicationConfig applicationConfig = new ApplicationConfig();
    applicationConfig.setName("generic-call-consumer");
    RegistryConfig registryConfig = new RegistryConfig();
    registryConfig.setAddress("zookeeper://" + zookeeperHost + ":2181");
    ReferenceConfig<GenericService> referenceConfig = new ReferenceConfig<>();
    referenceConfig.setInterface("org.apache.dubbo.samples.generic.call.api.HelloService");
    applicationConfig.setRegistry(registryConfig);
    referenceConfig.setApplication(applicationConfig);
    referenceConfig.setGeneric(true);
    referenceConfig.setAsync(true);
    referenceConfig.setTimeout(7000);
    genericService = referenceConfig.get();
}
 
Example #14
Source File: DubboProvider.java    From alibabacloud-microservice-demo with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    ServiceConfig<GreetingsService> service = new ServiceConfig<>();
    service.setApplication(new ApplicationConfig("dubbo-provider"));
    service.setRegistry(new RegistryConfig("nacos://127.0.0.1:8848"));
    service.setInterface(GreetingsService.class);
    service.setRef(new GreetingsServiceImpl());
    service.export();

    System.out.println("dubbo service started");
    new CountDownLatch(1).await();
}
 
Example #15
Source File: DubboConsumer.java    From alibabacloud-microservice-demo with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    ReferenceConfig<GreetingsService> reference = new ReferenceConfig<>();
    reference.setApplication(new ApplicationConfig("dubbo-consumer"));
    reference.setRegistry(new RegistryConfig("nacos://127.0.0.1:8848"));
    reference.setInterface(GreetingsService.class);
    GreetingsService service = reference.get();
    String message = service.sayHi("dubbo");
    System.out.println(message);
}
 
Example #16
Source File: MonitorServiceIT.java    From dubbo-samples with Apache License 2.0 5 votes vote down vote up
@Test
public void test() throws Exception {
    for (int i = 0; i < 10; i++) {
        demoService.sayHello("world");
        Thread.sleep(50);
    }

    ReferenceConfig<MonitorService> reference = new ReferenceConfig<>();
    reference.setApplication(new ApplicationConfig("demo-consumer"));
    reference.setRegistry(new RegistryConfig("zookeeper://" + zookeeperHost + ":2181"));
    reference.setInterface(MonitorService.class);
    reference.setFilter("-monitor");
    MonitorService service = reference.get();
    List<URL> stats = service.lookup(null);

    boolean countProvider = false;
    boolean countConsumer = false;
    for (URL stat : stats) {
        Assert.assertEquals("count", stat.getProtocol());
        Assert.assertEquals("org.apache.dubbo.samples.monitor.api.DemoService/sayHello", stat.getPath());
        if (stat.getParameter("application").equals("demo-provider")) {
            countProvider = true;
        }
        if (stat.getParameter("application").equals("demo-consumer")) {
            countConsumer = true;
        }
        System.out.println(stat);
    }
    Assert.assertTrue(countConsumer && countProvider);
}
 
Example #17
Source File: MonitorServiceIT.java    From dubbo-samples with Apache License 2.0 5 votes vote down vote up
@Before
    public void setUp() throws Exception {
        ServiceConfig<MonitorService> service = new ServiceConfig<>();
        // FIXME: has to set application name to "demo-consumer"
        service.setApplication(new ApplicationConfig("demo-consumer"));
        service.setRegistry(new RegistryConfig("zookeeper://" + zookeeperHost + ":2181"));
//        MonitorConfig monitorConfig = new MonitorConfig();
//        monitorConfig.setProtocol("registry");
//        monitorConfig.setInterval("100");
//        service.setMonitor(monitorConfig);
        service.setInterface(MonitorService.class);
        service.setFilter("-monitor");
        service.setRef(new MonitorServiceImpl());
        service.export();
    }
 
Example #18
Source File: MockClient.java    From java-specialagent with Apache License 2.0 5 votes vote down vote up
public MockClient(final String ip, final int port) {
  client = new ReferenceConfig<>();
  client.setApplication(new ApplicationConfig("test"));
  client.setInterface(GreeterService.class);
  client.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
  // client.setFilter("traceFilter");
  client.setUrl("dubbo://" + ip + ":" + port);
  client.setTimeout(10000);
  client.setCheck(false);
  client.setScope("local");
  client.setInjvm(true);
}
 
Example #19
Source File: GreetingServiceIT.java    From dubbo-samples with Apache License 2.0 5 votes vote down vote up
@Test
public void test() {
    ReferenceConfig<GreetingsService> reference = new ReferenceConfig<>();
    reference.setApplication(new ApplicationConfig("first-dubbo-consumer"));
    reference.setRegistry(new RegistryConfig("zookeeper://" + zookeeperHost + ":2181"));
    reference.setInterface(GreetingsService.class);
    GreetingsService service = reference.get();
    String message = service.sayHi("dubbo");
    TestCase.assertEquals(message, "hi, dubbo");
}
 
Example #20
Source File: Application.java    From dubbo-samples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    ServiceConfig<GreetingsService> service = new ServiceConfig<>();
    service.setApplication(new ApplicationConfig("first-dubbo-provider"));
    service.setRegistry(new RegistryConfig("zookeeper://" + zookeeperHost + ":2181"));
    service.setInterface(GreetingsService.class);
    service.setRef(new GreetingsServiceImpl());
    service.export();

    System.out.println("dubbo service started");
    new CountDownLatch(1).await();
}
 
Example #21
Source File: Application.java    From dubbo-samples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    ReferenceConfig<GreetingsService> reference = new ReferenceConfig<>();
    reference.setApplication(new ApplicationConfig("first-dubbo-consumer"));
    reference.setRegistry(new RegistryConfig("zookeeper://" + zookeeperHost + ":2181"));
    reference.setInterface(GreetingsService.class);
    GreetingsService service = reference.get();
    String message = service.sayHi("dubbo");
    System.out.println(message);
}
 
Example #22
Source File: MockServer.java    From java-specialagent with Apache License 2.0 5 votes vote down vote up
MockServer() {
  linkLocalIp = NetUtils.getLocalAddress().getHostAddress();
  if (linkLocalIp != null) {
    // avoid dubbo's logic which might pick docker ip
    System.setProperty(Constants.DUBBO_IP_TO_BIND, linkLocalIp);
    System.setProperty(Constants.DUBBO_IP_TO_REGISTRY, linkLocalIp);
  }

  service = new ServiceConfig<>();
  service.setApplication(new ApplicationConfig("test"));
  service.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
  service.setProtocol(new ProtocolConfig("dubbo", TestUtil.nextFreePort()));
  service.setInterface(GreeterService.class);
  service.setRef(new GreeterServiceImpl());
}
 
Example #23
Source File: GenericServiceTest.java    From jmeter-plugins-for-apache-dubbo with Apache License 2.0 5 votes vote down vote up
@Test
public void testZk() {
    for(int i=0;i<5;i++) {
        ApplicationConfig application = new ApplicationConfig();
        application.setName("api-generic-consumer");
        ReferenceConfig<GenericService> reference = new ReferenceConfig<>();
        reference.setVersion("1.0.0");
        RegistryConfig registry = new RegistryConfig();
        registry.setProtocol(Constants.REGISTRY_ZOOKEEPER);
        registry.setAddress("192.168.0.44:2181,192.168.0.44:2182,192.168.0.44:2183");
        registry.setTimeout(10000);
        reference.setRegistry(registry);
        ConfigCenterConfig cc = new ConfigCenterConfig();
        cc.setAddress("192.168.0.58:2181,192.168.0.59:2181,192.168.0.60:2181");
        cc.setProtocol(Constants.REGISTRY_ZOOKEEPER);
        cc.setTimeout(Long.valueOf("10000"));
        cc.setGroup("");
        cc.setNamespace("");
        reference.setConfigCenter(cc);
        reference.setTimeout(2000);
        reference.setGeneric(true);
        reference.setApplication(application);
        reference.setInterface("com.jiuyescm.account.api.IUserService");
        GenericService genericService = reference.get();
        Object obj = genericService.$invoke("getUserById", new String[]{Long.class.getName()}, new Long[]{1L});
        String json = JsonUtils.toJson(obj);
        System.out.println(json);
    }
}
 
Example #24
Source File: Dubbo27ITest.java    From java-specialagent with Apache License 2.0 5 votes vote down vote up
private static ServiceConfig<GreeterService> getService() {
  final ServiceConfig<GreeterService> service = new ServiceConfig<>();
  service.setApplication(new ApplicationConfig("test"));
  service.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
  service.setProtocol(new ProtocolConfig("dubbo", TestUtil.nextFreePort()));
  service.setInterface(GreeterService.class);
  service.setRef(new GreeterServiceImpl());
  return service;
}
 
Example #25
Source File: ChronusAutoConfiguration.java    From chronus with Apache License 2.0 4 votes vote down vote up
public ChronusAutoConfiguration(ObjectProvider<ApplicationConfig> applicationConfig,
                                ObjectProvider<RegistryConfig> registryConfig) {
    this.applicationConfig = applicationConfig.getIfAvailable();
    this.registryConfig = registryConfig.getIfAvailable();
}
 
Example #26
Source File: SslBasicProvider.java    From dubbo-samples with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    new EmbeddedZooKeeper(2181, false).start();
    // wait for embedded zookeeper start completely.
    Thread.sleep(1000);

    SslConfig sslConfig = new SslConfig();
    if (args.length > 0) {
        if (args.length < 2 || args.length > 3) {
            System.out.println(
                    "USAGE: BasicProvider certChainFilePath privateKeyFilePath " +
                            "[trustCertCollectionFilePath]\n Specify 'trustCertCollectionFilePath' only if you want " +
                            "need Mutual TLS.");
            System.exit(0);
        }


        sslConfig.setServerKeyCertChainPath(args[0]);
        sslConfig.setServerPrivateKeyPath(args[1]);
        if (args.length == 3) {
            sslConfig.setServerTrustCertCollectionPath(args[2]);
        }
    }

    ProtocolConfig protocolConfig = new ProtocolConfig("dubbo");
    protocolConfig.setSslEnabled(true);

    DubboBootstrap bootstrap = DubboBootstrap.getInstance();
    bootstrap.application(new ApplicationConfig("ssl-provider"))
             .registry(new RegistryConfig("zookeeper://127.0.0.1:2181"))
             .protocol(protocolConfig)
             .ssl(sslConfig);

    ServiceConfig<DemoService> service = new ServiceConfig<>();
    service.setInterface(DemoService.class);
    service.setRef(new DemoServiceImpl());

    bootstrap.service(service);
    bootstrap.start();

    System.out.println("dubbo service started");
    new CountDownLatch(1).await();
}
 
Example #27
Source File: ApacheDubboInstrumentationTest.java    From apm-agent-java with Apache License 2.0 4 votes vote down vote up
@Override
protected DubboTestApi buildDubboTestApi() {
    ApplicationConfig providerAppConfig = new ApplicationConfig();
    providerAppConfig.setName("dubbo-demo");

    ProtocolConfig protocolConfig = new ProtocolConfig();
    protocolConfig.setName("dubbo");
    protocolConfig.setPort(getPort());
    protocolConfig.setThreads(10);

    RegistryConfig registryConfig = new RegistryConfig();
    registryConfig.setAddress("N/A");

    serviceConfig = new ServiceConfig<>();
    serviceConfig.setApplication(providerAppConfig);
    serviceConfig.setProtocol(protocolConfig);
    serviceConfig.setInterface(DubboTestApi.class);
    serviceConfig.setRef(new DubboTestApiImpl());
    serviceConfig.setRegistry(registryConfig);
    serviceConfig.export();

    referenceConfig = new ReferenceConfig<>();
    referenceConfig.setApplication(providerAppConfig);
    referenceConfig.setInterface(DubboTestApi.class);
    referenceConfig.setUrl("dubbo://localhost:" + getPort());
    referenceConfig.setTimeout(3000);

    List<MethodConfig> methodConfigList = new LinkedList<>();
    referenceConfig.setMethods(methodConfigList);

    MethodConfig asyncConfig = new MethodConfig();
    asyncConfig.setName("async");
    asyncConfig.setAsync(true);
    methodConfigList.add(asyncConfig);

    MethodConfig asyncNoReturnConfig = new MethodConfig();
    asyncNoReturnConfig.setName("asyncNoReturn");
    asyncNoReturnConfig.setAsync(true);
    asyncNoReturnConfig.setReturn(false);
    methodConfigList.add(asyncNoReturnConfig);

    return referenceConfig.get();
}
 
Example #28
Source File: DubboAutoConfigurationOnMultipleConfigTest.java    From dubbo-spring-boot-project with Apache License 2.0 4 votes vote down vote up
@Test
public void testApplicationContext() {

    /**
     * Multiple {@link ApplicationConfig}
     */
    Map<String, ApplicationConfig> applications = beansOfTypeIncludingAncestors(applicationContext, ApplicationConfig.class);

    Assert.assertEquals(1, applications.size());

    /**
     * Multiple {@link ModuleConfig}
     */
    Map<String, ModuleConfig> modules = beansOfTypeIncludingAncestors(applicationContext, ModuleConfig.class);

    Assert.assertEquals(1, modules.size());

    /**
     * Multiple {@link RegistryConfig}
     */
    Map<String, RegistryConfig> registries = beansOfTypeIncludingAncestors(applicationContext, RegistryConfig.class);

    Assert.assertEquals(1, registries.size());

    /**
     * Multiple {@link ProtocolConfig}
     */
    Map<String, ProtocolConfig> protocols = beansOfTypeIncludingAncestors(applicationContext, ProtocolConfig.class);

    Assert.assertEquals(1, protocols.size());

    /**
     * Multiple {@link MonitorConfig}
     */
    Map<String, MonitorConfig> monitors = beansOfTypeIncludingAncestors(applicationContext, MonitorConfig.class);

    Assert.assertEquals(1, monitors.size());

    /**
     * Multiple {@link ProviderConfig}
     */
    Map<String, ProviderConfig> providers = beansOfTypeIncludingAncestors(applicationContext, ProviderConfig.class);

    Assert.assertEquals(1, providers.size());

    /**
     * Multiple {@link ConsumerConfig}
     */
    Map<String, ConsumerConfig> consumers = beansOfTypeIncludingAncestors(applicationContext, ConsumerConfig.class);

    Assert.assertEquals(1, consumers.size());

}
 
Example #29
Source File: DubboConfigurationProperties.java    From dubbo-spring-boot-project with Apache License 2.0 4 votes vote down vote up
public void setRegistries(Map<String, RegistryConfig> registries) {
    this.registries = registries;
}
 
Example #30
Source File: DubboConfigurationProperties.java    From dubbo-spring-boot-project with Apache License 2.0 4 votes vote down vote up
public Map<String, RegistryConfig> getRegistries() {
    return registries;
}