com.alibaba.dubbo.config.MethodConfig Java Examples

The following examples show how to use com.alibaba.dubbo.config.MethodConfig. 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: 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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
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 #13
Source File: AlibabaDubboInstrumentationTest.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-provider");

    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();

    ApplicationConfig consumerApp = new ApplicationConfig();
    consumerApp.setName("dubbo-consumer");
    referenceConfig = new ReferenceConfig<>();
    referenceConfig.setApplication(consumerApp);
    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 #14
Source File: DubboProperties.java    From spring-boot-starter-dubbo with Apache License 2.0 4 votes vote down vote up
public MethodConfig getMethod() {
	return method;
}
 
Example #15
Source File: DubboProperties.java    From spring-boot-starter-dubbo with Apache License 2.0 4 votes vote down vote up
public void setMethod(MethodConfig method) {
	this.method = method;
}