Search in sources :

Example 11 with ProtocolConfig

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

the class MockServiceConfig method mockProtocolConfig.

protected static ProtocolConfig mockProtocolConfig(String protocolName) {
    ProtocolConfig pc = createProtocol(protocolName);
    pc.setEndpointFactory("mockEndpoint");
    return pc;
}
Also used : ProtocolConfig(com.weibo.api.motan.config.ProtocolConfig)

Example 12 with ProtocolConfig

use of com.weibo.api.motan.config.ProtocolConfig 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(1000);
    // 配置注册中心直连调用
    RegistryConfig registry = new RegistryConfig();
    // use direct registry
    registry.setRegProtocol("direct");
    registry.setAddress("127.0.0.1:8002");
    // use ZooKeeper registry
    // registry.setRegProtocol("zookeeper");
    // registry.setAddress("127.0.0.1:2181");
    motanDemoServiceReferer.setRegistry(registry);
    // 配置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

ProtocolConfig (com.weibo.api.motan.config.ProtocolConfig)12 RegistryConfig (com.weibo.api.motan.config.RegistryConfig)7 Before (org.junit.Before)3 RefererConfig (com.weibo.api.motan.config.RefererConfig)2 MotanDemoService (com.weibo.motan.demo.service.MotanDemoService)2 BasicRefererInterfaceConfig (com.weibo.api.motan.config.BasicRefererInterfaceConfig)1 ExtConfig (com.weibo.api.motan.config.ExtConfig)1 ServiceConfig (com.weibo.api.motan.config.ServiceConfig)1 MotanFrameworkException (com.weibo.api.motan.exception.MotanFrameworkException)1 RestfulServletContainerListener (com.weibo.api.motan.protocol.restful.support.servlet.RestfulServletContainerListener)1 CommonHandler (com.weibo.api.motan.proxy.CommonHandler)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Context (org.apache.catalina.Context)1 Wrapper (org.apache.catalina.Wrapper)1 Tomcat (org.apache.catalina.startup.Tomcat)1 HttpServletDispatcher (org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher)1 Test (org.junit.Test)1 BeansException (org.springframework.beans.BeansException)1