Search in sources :

Example 1 with ServiceConfig

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;
}
Also used : ServiceConfig(com.weibo.api.motan.config.ServiceConfig) IWorld(com.weibo.api.motan.protocol.example.IWorld) MockWorld(com.weibo.api.motan.protocol.example.MockWorld)

Example 2 with 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...");
}
Also used : RegistryConfig(com.weibo.api.motan.config.RegistryConfig) MotanDemoService(com.weibo.motan.demo.service.MotanDemoService) ServiceConfig(com.weibo.api.motan.config.ServiceConfig) ProtocolConfig(com.weibo.api.motan.config.ProtocolConfig)

Example 3 with ServiceConfig

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);
}
Also used : ServiceConfig(com.weibo.api.motan.config.ServiceConfig) Test(org.junit.Test)

Aggregations

ServiceConfig (com.weibo.api.motan.config.ServiceConfig)3 ProtocolConfig (com.weibo.api.motan.config.ProtocolConfig)1 RegistryConfig (com.weibo.api.motan.config.RegistryConfig)1 IWorld (com.weibo.api.motan.protocol.example.IWorld)1 MockWorld (com.weibo.api.motan.protocol.example.MockWorld)1 MotanDemoService (com.weibo.motan.demo.service.MotanDemoService)1 Test (org.junit.Test)1