use of com.weibo.api.motan.config.ServiceConfig in project motan by weibocom.
the class MockServiceConfig method mockIWorldServiceConfig.
protected static ServiceConfig<IWorld> mockIWorldServiceConfig() {
ServiceConfig<IWorld> serviceConfig = new ServiceConfig<IWorld>();
serviceConfig.setRef(new MockWorld());
serviceConfig.setApplication(application);
serviceConfig.setModule(module);
serviceConfig.setCheck("true");
serviceConfig.setInterface(IWorld.class);
serviceConfig.setGroup(group);
serviceConfig.setShareChannel(true);
return serviceConfig;
}
use of com.weibo.api.motan.config.ServiceConfig in project motan by weibocom.
the class MotanApiExportDemo method main.
public static void main(String[] args) throws InterruptedException {
ServiceConfig<MotanDemoService> motanDemoService = new ServiceConfig<MotanDemoService>();
// 设置接口及实现类
motanDemoService.setInterface(MotanDemoService.class);
motanDemoService.setRef(new MotanDemoServiceImpl());
// 配置服务的group以及版本号
motanDemoService.setGroup("motan-demo-rpc");
motanDemoService.setVersion("1.0");
// 配置注册中心直连调用
// RegistryConfig directRegistry = new RegistryConfig();
// directRegistry.setRegProtocol("local");
// directRegistry.setCheck("false"); //不检查是否注册成功
// motanDemoService.setRegistry(directRegistry);
// 配置ZooKeeper注册中心
RegistryConfig zookeeperRegistry = new RegistryConfig();
zookeeperRegistry.setRegProtocol("zookeeper");
zookeeperRegistry.setAddress("127.0.0.1:2181");
motanDemoService.setRegistry(zookeeperRegistry);
// 配置RPC协议
ProtocolConfig protocol = new ProtocolConfig();
protocol.setId("motan");
protocol.setName("motan");
motanDemoService.setProtocol(protocol);
motanDemoService.setExport("motan:8002");
motanDemoService.export();
MotanSwitcherUtil.setSwitcherValue(MotanConstants.REGISTRY_HEARTBEAT_SWITCHER, true);
System.out.println("server start...");
}
use of com.weibo.api.motan.config.ServiceConfig in project motan by weibocom.
the class SpringSupportTest method testServiceConfig.
@SuppressWarnings("rawtypes")
@Test
public void testServiceConfig() {
Map<String, ServiceConfig> map = cp.getBeansOfType(ServiceConfig.class);
assertEquals(3, map.size());
ServiceConfig serviceTest = map.get("serviceTest");
ServiceConfig serviceTestWithMethodConfig = map.get("serviceTestWithMethodConfig");
ServiceConfig serviceTestInjvm = map.get("serviceTestInjvm");
assertTrue(serviceTest != null && serviceTestWithMethodConfig != null && serviceTestInjvm != null);
}
Aggregations