Search in sources :

Example 6 with RegistryConfig

use of com.weibo.api.motan.config.RegistryConfig in project motan by weibocom.

the class MockServiceConfig method createLocalRegistryConfig.

protected static RegistryConfig createLocalRegistryConfig(String protocol, String name) {
    RegistryConfig rc = new RegistryConfig();
    rc.setRegProtocol(protocol);
    rc.setName(name);
    rc.setId(rc.getName());
    return rc;
}
Also used : RegistryConfig(com.weibo.api.motan.config.RegistryConfig)

Example 7 with RegistryConfig

use of com.weibo.api.motan.config.RegistryConfig in project motan by weibocom.

the class MockServiceConfig method getMultiRegister.

protected static List<RegistryConfig> getMultiRegister(String... registerName) {
    List<RegistryConfig> registries = new ArrayList<RegistryConfig>();
    for (String register : registerName) {
        RegistryConfig registryConfig = createLocalRegistryConfig(register, register);
        registries.add(registryConfig);
    }
    return registries;
}
Also used : RegistryConfig(com.weibo.api.motan.config.RegistryConfig) ArrayList(java.util.ArrayList)

Example 8 with RegistryConfig

use of com.weibo.api.motan.config.RegistryConfig in project motan by weibocom.

the class MockServiceConfig method createRemoteRegistryConfig.

protected static RegistryConfig createRemoteRegistryConfig(String protocol, String name, String address, int port) {
    RegistryConfig rc = new RegistryConfig();
    rc.setRegProtocol(protocol);
    rc.setName(name);
    rc.setId(rc.getName());
    rc.setAddress(address);
    rc.setPort(port);
    return rc;
}
Also used : RegistryConfig(com.weibo.api.motan.config.RegistryConfig)

Example 9 with RegistryConfig

use of com.weibo.api.motan.config.RegistryConfig in project motan by weibocom.

the class MotanApiClientDemo method main.

public static void main(String[] args) {
    RefererConfig<MotanDemoService> motanDemoServiceReferer = new RefererConfig<MotanDemoService>();
    // 设置接口及实现类
    motanDemoServiceReferer.setInterface(MotanDemoService.class);
    // 配置服务的group以及版本号
    motanDemoServiceReferer.setGroup("motan-demo-rpc");
    motanDemoServiceReferer.setVersion("1.0");
    motanDemoServiceReferer.setRequestTimeout(300);
    // 配置注册中心直连调用
    // RegistryConfig directRegistry = new RegistryConfig();
    // directRegistry.setRegProtocol("local");
    // motanDemoServiceReferer.setRegistry(directRegistry);
    // 配置ZooKeeper注册中心
    RegistryConfig zookeeperRegistry = new RegistryConfig();
    zookeeperRegistry.setRegProtocol("zookeeper");
    zookeeperRegistry.setAddress("127.0.0.1:2181");
    motanDemoServiceReferer.setRegistry(zookeeperRegistry);
    // 配置RPC协议
    ProtocolConfig protocol = new ProtocolConfig();
    protocol.setId("motan");
    protocol.setName("motan");
    motanDemoServiceReferer.setProtocol(protocol);
    // motanDemoServiceReferer.setDirectUrl("localhost:8002");  // 注册中心直连调用需添加此配置
    // 使用服务
    MotanDemoService service = motanDemoServiceReferer.getRef();
    System.out.println(service.hello("motan"));
    System.exit(0);
}
Also used : RegistryConfig(com.weibo.api.motan.config.RegistryConfig) MotanDemoService(com.weibo.motan.demo.service.MotanDemoService) ProtocolConfig(com.weibo.api.motan.config.ProtocolConfig) RefererConfig(com.weibo.api.motan.config.RefererConfig)

Aggregations

RegistryConfig (com.weibo.api.motan.config.RegistryConfig)9 ProtocolConfig (com.weibo.api.motan.config.ProtocolConfig)4 ExtConfig (com.weibo.api.motan.config.ExtConfig)2 MotanDemoService (com.weibo.motan.demo.service.MotanDemoService)2 BeansException (org.springframework.beans.BeansException)2 BeanInitializationException (org.springframework.beans.factory.BeanInitializationException)2 BasicRefererInterfaceConfig (com.weibo.api.motan.config.BasicRefererInterfaceConfig)1 BasicServiceInterfaceConfig (com.weibo.api.motan.config.BasicServiceInterfaceConfig)1 RefererConfig (com.weibo.api.motan.config.RefererConfig)1 ServiceConfig (com.weibo.api.motan.config.ServiceConfig)1 MotanService (com.weibo.api.motan.config.springsupport.annotation.MotanService)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1