Java Code Examples for com.alibaba.dubbo.config.RegistryConfig#setProtocol()

The following examples show how to use com.alibaba.dubbo.config.RegistryConfig#setProtocol() . 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: InvokerSideConfigUrlTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
private void initRefConf() {

        appConfForConsumer = new ApplicationConfig();
        appConfForReference = new ApplicationConfig();
        regConfForConsumer = new RegistryConfig();
        regConfForReference = new RegistryConfig();
        methodConfForReference = new MethodConfig();

        refConf = new ReferenceConfig<DemoService>();
        consumerConf = new ConsumerConfig();

        methodConfForReference.setName("sayName");
        regConfForReference.setAddress("127.0.0.1:9090");
        regConfForReference.setProtocol("mockregistry");
        appConfForReference.setName("ConfigTests");
        refConf.setInterface("com.alibaba.dubbo.config.api.DemoService");

        refConf.setApplication(appConfForReference);
        consumerConf.setApplication(appConfForConsumer);

        refConf.setRegistry(regConfForReference);
        consumerConf.setRegistry(regConfForConsumer);

        refConf.setConsumer(consumerConf);

        refConf.setMethods(Arrays.asList(new MethodConfig[]{methodConfForReference}));

        refConf.setScope(Constants.SCOPE_REMOTE);
    }
 
Example 2
Source File: UrlTestBase.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
protected void initServConf() {

    appConfForProvider = new ApplicationConfig();
    appConfForService = new ApplicationConfig();
    regConfForProvider = new RegistryConfig();
    regConfForService = new RegistryConfig();
    provConf = new ProviderConfig();
    protoConfForProvider = new ProtocolConfig();
    protoConfForService = new ProtocolConfig();
    methodConfForService = new MethodConfig();
    servConf = new ServiceConfig<DemoService>();

    provConf.setApplication(appConfForProvider);
    servConf.setApplication(appConfForService);

    provConf.setRegistry(regConfForProvider);
    servConf.setRegistry(regConfForService);

    provConf.setProtocols(Arrays.asList(new ProtocolConfig[]{protoConfForProvider}));
    servConf.setProtocols(Arrays.asList(new ProtocolConfig[]{protoConfForService}));

    servConf.setMethods(Arrays.asList(new MethodConfig[]{methodConfForService}));
    servConf.setProvider(provConf);

    servConf.setRef(demoService);
    servConf.setInterfaceClass(DemoService.class);

    methodConfForService.setName("sayName");
    regConfForService.setAddress("127.0.0.1:9090");
    regConfForService.setProtocol("mockregistry");
    appConfForService.setName("ConfigTests");
}
 
Example 3
Source File: DubboServiceConfig.java    From dubbo-mock with Apache License 2.0 5 votes vote down vote up
public static RegistryConfig createRegistry(String address, int timeout) {
    RegistryConfig registry = new RegistryConfig();
    registry.setProtocol("zookeeper");
    registry.setAddress(address);
    registry.setTimeout(timeout);
    return registry;
}
 
Example 4
Source File: InvokerSideConfigUrlTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private void initRefConf(){
    
    appConfForConsumer      = new ApplicationConfig();
    appConfForReference     = new ApplicationConfig();
    regConfForConsumer      = new RegistryConfig();
    regConfForReference     = new RegistryConfig();
    methodConfForReference  = new MethodConfig();
    
    refConf                 = new ReferenceConfig<DemoService>();
    consumerConf            = new ConsumerConfig();

    methodConfForReference.setName("sayName");
    regConfForReference.setAddress("127.0.0.1:9090");
    regConfForReference.setProtocol("mockregistry");
    appConfForReference.setName("ConfigTests");
    refConf.setInterface("com.alibaba.dubbo.config.api.DemoService");
    
    refConf.setApplication(appConfForReference);
    consumerConf.setApplication(appConfForConsumer);
    
    refConf.setRegistry(regConfForReference);
    consumerConf.setRegistry(regConfForConsumer);
    
    refConf.setConsumer(consumerConf);
    
    refConf.setMethods(Arrays.asList(new MethodConfig[]{methodConfForReference}));
    
    refConf.setScope(Constants.SCOPE_REMOTE);
}
 
Example 5
Source File: UrlTestBase.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
protected void initServConf() {
    
    appConfForProvider = new ApplicationConfig();
    appConfForService = new ApplicationConfig();
    regConfForProvider = new RegistryConfig();
    regConfForService = new RegistryConfig();
    provConf = new ProviderConfig();
    protoConfForProvider = new ProtocolConfig();
    protoConfForService = new ProtocolConfig();
    methodConfForService = new MethodConfig();
    servConf = new ServiceConfig<DemoService>();
    
    provConf.setApplication(appConfForProvider);
    servConf.setApplication(appConfForService);
    
    provConf.setRegistry(regConfForProvider);
    servConf.setRegistry(regConfForService);
    
    provConf.setProtocols(Arrays.asList(new ProtocolConfig[]{protoConfForProvider}));
    servConf.setProtocols(Arrays.asList(new ProtocolConfig[]{protoConfForService}));
    
    servConf.setMethods(Arrays.asList(new MethodConfig[]{methodConfForService}));
    servConf.setProvider(provConf);
    
    servConf.setRef(demoService);
    servConf.setInterfaceClass(DemoService.class);
   
    methodConfForService.setName("sayName");
    regConfForService.setAddress("127.0.0.1:9090");
    regConfForService.setProtocol("mockregistry");
    appConfForService.setName("ConfigTests");
}
 
Example 6
Source File: InvokerSideConfigUrlTest.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
private void initRefConf(){
    
    appConfForConsumer      = new ApplicationConfig();
    appConfForReference     = new ApplicationConfig();
    regConfForConsumer      = new RegistryConfig();
    regConfForReference     = new RegistryConfig();
    methodConfForReference  = new MethodConfig();
    
    refConf                 = new ReferenceConfig<DemoService>();
    consumerConf            = new ConsumerConfig();

    methodConfForReference.setName("sayName");
    regConfForReference.setAddress("127.0.0.1:9090");
    regConfForReference.setProtocol("mockregistry");
    appConfForReference.setName("ConfigTests");
    refConf.setInterface("com.alibaba.dubbo.config.api.DemoService");
    
    refConf.setApplication(appConfForReference);
    consumerConf.setApplication(appConfForConsumer);
    
    refConf.setRegistry(regConfForReference);
    consumerConf.setRegistry(regConfForConsumer);
    
    refConf.setConsumer(consumerConf);
    
    refConf.setMethods(Arrays.asList(new MethodConfig[]{methodConfForReference}));
    
    refConf.setScope(Constants.SCOPE_REMOTE);
}
 
Example 7
Source File: UrlTestBase.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
protected void initServConf() {
    
    appConfForProvider = new ApplicationConfig();
    appConfForService = new ApplicationConfig();
    regConfForProvider = new RegistryConfig();
    regConfForService = new RegistryConfig();
    provConf = new ProviderConfig();
    protoConfForProvider = new ProtocolConfig();
    protoConfForService = new ProtocolConfig();
    methodConfForService = new MethodConfig();
    servConf = new ServiceConfig<DemoService>();
    
    provConf.setApplication(appConfForProvider);
    servConf.setApplication(appConfForService);
    
    provConf.setRegistry(regConfForProvider);
    servConf.setRegistry(regConfForService);
    
    provConf.setProtocols(Arrays.asList(new ProtocolConfig[]{protoConfForProvider}));
    servConf.setProtocols(Arrays.asList(new ProtocolConfig[]{protoConfForService}));
    
    servConf.setMethods(Arrays.asList(new MethodConfig[]{methodConfForService}));
    servConf.setProvider(provConf);
    
    servConf.setRef(demoService);
    servConf.setInterfaceClass(DemoService.class);
   
    methodConfForService.setName("sayName");
    regConfForService.setAddress("127.0.0.1:9090");
    regConfForService.setProtocol("mockregistry");
    appConfForService.setName("ConfigTests");
}
 
Example 8
Source File: InvokerSideConfigUrlTest.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
private void initRefConf(){
    
    appConfForConsumer      = new ApplicationConfig();
    appConfForReference     = new ApplicationConfig();
    regConfForConsumer      = new RegistryConfig();
    regConfForReference     = new RegistryConfig();
    methodConfForReference  = new MethodConfig();
    
    refConf                 = new ReferenceConfig<DemoService>();
    consumerConf            = new ConsumerConfig();

    methodConfForReference.setName("sayName");
    regConfForReference.setAddress("127.0.0.1:9090");
    regConfForReference.setProtocol("mockregistry");
    appConfForReference.setName("ConfigTests");
    refConf.setInterface("com.alibaba.dubbo.config.api.DemoService");
    
    refConf.setApplication(appConfForReference);
    consumerConf.setApplication(appConfForConsumer);
    
    refConf.setRegistry(regConfForReference);
    consumerConf.setRegistry(regConfForConsumer);
    
    refConf.setConsumer(consumerConf);
    
    refConf.setMethods(Arrays.asList(new MethodConfig[]{methodConfForReference}));
    
    refConf.setScope(Constants.SCOPE_REMOTE);
}
 
Example 9
Source File: UrlTestBase.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
protected void initServConf() {
    
    appConfForProvider = new ApplicationConfig();
    appConfForService = new ApplicationConfig();
    regConfForProvider = new RegistryConfig();
    regConfForService = new RegistryConfig();
    provConf = new ProviderConfig();
    protoConfForProvider = new ProtocolConfig();
    protoConfForService = new ProtocolConfig();
    methodConfForService = new MethodConfig();
    servConf = new ServiceConfig<DemoService>();
    
    provConf.setApplication(appConfForProvider);
    servConf.setApplication(appConfForService);
    
    provConf.setRegistry(regConfForProvider);
    servConf.setRegistry(regConfForService);
    
    provConf.setProtocols(Arrays.asList(new ProtocolConfig[]{protoConfForProvider}));
    servConf.setProtocols(Arrays.asList(new ProtocolConfig[]{protoConfForService}));
    
    servConf.setMethods(Arrays.asList(new MethodConfig[]{methodConfForService}));
    servConf.setProvider(provConf);
    
    servConf.setRef(demoService);
    servConf.setInterfaceClass(DemoService.class);
   
    methodConfForService.setName("sayName");
    regConfForService.setAddress("127.0.0.1:9090");
    regConfForService.setProtocol("mockregistry");
    appConfForService.setName("ConfigTests");
}
 
Example 10
Source File: InvokerSideConfigUrlTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private void initRefConf(){
    
    appConfForConsumer      = new ApplicationConfig();
    appConfForReference     = new ApplicationConfig();
    regConfForConsumer      = new RegistryConfig();
    regConfForReference     = new RegistryConfig();
    methodConfForReference  = new MethodConfig();
    
    refConf                 = new ReferenceConfig<DemoService>();
    consumerConf            = new ConsumerConfig();

    methodConfForReference.setName("sayName");
    regConfForReference.setAddress("127.0.0.1:9090");
    regConfForReference.setProtocol("mockregistry");
    appConfForReference.setName("ConfigTests");
    refConf.setInterface("com.alibaba.dubbo.config.api.DemoService");
    
    refConf.setApplication(appConfForReference);
    consumerConf.setApplication(appConfForConsumer);
    
    refConf.setRegistry(regConfForReference);
    consumerConf.setRegistry(regConfForConsumer);
    
    refConf.setConsumer(consumerConf);
    
    refConf.setMethods(Arrays.asList(new MethodConfig[]{methodConfForReference}));
    
    refConf.setScope(Constants.SCOPE_REMOTE);
}
 
Example 11
Source File: UrlTestBase.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
protected void initServConf() {
    
    appConfForProvider = new ApplicationConfig();
    appConfForService = new ApplicationConfig();
    regConfForProvider = new RegistryConfig();
    regConfForService = new RegistryConfig();
    provConf = new ProviderConfig();
    protoConfForProvider = new ProtocolConfig();
    protoConfForService = new ProtocolConfig();
    methodConfForService = new MethodConfig();
    servConf = new ServiceConfig<DemoService>();
    
    provConf.setApplication(appConfForProvider);
    servConf.setApplication(appConfForService);
    
    provConf.setRegistry(regConfForProvider);
    servConf.setRegistry(regConfForService);
    
    provConf.setProtocols(Arrays.asList(new ProtocolConfig[]{protoConfForProvider}));
    servConf.setProtocols(Arrays.asList(new ProtocolConfig[]{protoConfForService}));
    
    servConf.setMethods(Arrays.asList(new MethodConfig[]{methodConfForService}));
    servConf.setProvider(provConf);
    
    servConf.setRef(demoService);
    servConf.setInterfaceClass(DemoService.class);
   
    methodConfForService.setName("sayName");
    regConfForService.setAddress("127.0.0.1:9090");
    regConfForService.setProtocol("mockregistry");
    appConfForService.setName("ConfigTests");
}
 
Example 12
Source File: DubboConfiguration.java    From cicada with MIT License 5 votes vote down vote up
@Bean
public List<RegistryConfig> dubboRegistries() {
  List<RegistryConfig> registrConfigs = new ArrayList<RegistryConfig>();
  String zkUrls = dubboProperty.getZkUrls();
  if (StringUtils.isNotBlank(zkUrls)) {
    String[] zkUrlsArr = zkUrls.split(",");
    for (String zkUrl : zkUrlsArr) {
      RegistryConfig registry = new RegistryConfig();
      registry.setAddress(zkUrl);
      registry.setProtocol("zookeeper");
      registrConfigs.add(registry);
    }
  }
  return registrConfigs;
}
 
Example 13
Source File: DubboConfiguration.java    From cicada with MIT License 5 votes vote down vote up
@Bean
public List<RegistryConfig> dubboRegistries() {
  List<RegistryConfig> registrConfigs = new ArrayList<RegistryConfig>();
  String zkUrls = dubboProperty.getZkUrls();
  if (StringUtils.isNotBlank(zkUrls)) {
    String[] zkUrlsArr = zkUrls.split(",");
    for (String zkUrl : zkUrlsArr) {
      RegistryConfig registry = new RegistryConfig();
      registry.setAddress(zkUrl);
      registry.setProtocol("zookeeper");
      registrConfigs.add(registry);
    }
  }
  return registrConfigs;
}
 
Example 14
Source File: InvokerSideConfigUrlTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private void initRefConf(){
    
    appConfForConsumer      = new ApplicationConfig();
    appConfForReference     = new ApplicationConfig();
    regConfForConsumer      = new RegistryConfig();
    regConfForReference     = new RegistryConfig();
    methodConfForReference  = new MethodConfig();
    
    refConf                 = new ReferenceConfig<DemoService>();
    consumerConf            = new ConsumerConfig();

    methodConfForReference.setName("sayName");
    regConfForReference.setAddress("127.0.0.1:9090");
    regConfForReference.setProtocol("mockregistry");
    appConfForReference.setName("ConfigTests");
    refConf.setInterface("com.alibaba.dubbo.config.api.DemoService");
    
    refConf.setApplication(appConfForReference);
    consumerConf.setApplication(appConfForConsumer);
    
    refConf.setRegistry(regConfForReference);
    consumerConf.setRegistry(regConfForConsumer);
    
    refConf.setConsumer(consumerConf);
    
    refConf.setMethods(Arrays.asList(new MethodConfig[]{methodConfForReference}));
    
    refConf.setScope(Constants.SCOPE_REMOTE);
}
 
Example 15
Source File: UrlTestBase.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
protected void initServConf() {
    
    appConfForProvider = new ApplicationConfig();
    appConfForService = new ApplicationConfig();
    regConfForProvider = new RegistryConfig();
    regConfForService = new RegistryConfig();
    provConf = new ProviderConfig();
    protoConfForProvider = new ProtocolConfig();
    protoConfForService = new ProtocolConfig();
    methodConfForService = new MethodConfig();
    servConf = new ServiceConfig<DemoService>();
    
    provConf.setApplication(appConfForProvider);
    servConf.setApplication(appConfForService);
    
    provConf.setRegistry(regConfForProvider);
    servConf.setRegistry(regConfForService);
    
    provConf.setProtocols(Arrays.asList(new ProtocolConfig[]{protoConfForProvider}));
    servConf.setProtocols(Arrays.asList(new ProtocolConfig[]{protoConfForService}));
    
    servConf.setMethods(Arrays.asList(new MethodConfig[]{methodConfForService}));
    servConf.setProvider(provConf);
    
    servConf.setRef(demoService);
    servConf.setInterfaceClass(DemoService.class);
   
    methodConfForService.setName("sayName");
    regConfForService.setAddress("127.0.0.1:9090");
    regConfForService.setProtocol("mockregistry");
    appConfForService.setName("ConfigTests");
}