本文整理汇总了Java中com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker类的典型用法代码示例。如果您正苦于以下问题:Java DubboInvoker类的具体用法?Java DubboInvoker怎么用?Java DubboInvoker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DubboInvoker类属于com.alibaba.dubbo.rpc.protocol.dubbo包,在下文中一共展示了DubboInvoker类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExport
import com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker; //导入依赖的package包/类
@Test
public void testExport() {
RegistryProtocol registryProtocol = new RegistryProtocol();
registryProtocol.setCluster(new FailfastCluster());
registryProtocol.setRegistryFactory(ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension());
Protocol dubboProtocol = DubboProtocol.getDubboProtocol();
registryProtocol.setProtocol(dubboProtocol);
URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl);
DubboInvoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class,
newRegistryUrl, new ExchangeClient[] { new MockedClient("10.20.20.20", 2222, true) });
Exporter<DemoService> exporter = registryProtocol.export(invoker);
Exporter<DemoService> exporter2 = registryProtocol.export(invoker);
//同一个invoker,多次export的exporter不同
Assert.assertNotSame(exporter, exporter2);
exporter.unexport();
exporter2.unexport();
}
示例2: testExport
import com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker; //导入依赖的package包/类
@Test
public void testExport() {
RegistryProtocol registryProtocol = new RegistryProtocol();
registryProtocol.setCluster(new FailfastCluster());
registryProtocol.setRegistryFactory(ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension());
Protocol dubboProtocol = DubboProtocol.getDubboProtocol();
registryProtocol.setProtocol(dubboProtocol);
URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl);
DubboInvoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class,
newRegistryUrl, new ExchangeClient[]{new MockedClient("10.20.20.20", 2222, true)});
Exporter<DemoService> exporter = registryProtocol.export(invoker);
Exporter<DemoService> exporter2 = registryProtocol.export(invoker);
//同一个invoker,多次export的exporter不同
Assert.assertNotSame(exporter, exporter2);
exporter.unexport();
exporter2.unexport();
}
示例3: testExportUrlNull
import com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testExportUrlNull() {
RegistryProtocol registryProtocol = new RegistryProtocol();
registryProtocol.setCluster(new FailfastCluster());
Protocol dubboProtocol = DubboProtocol.getDubboProtocol();
registryProtocol.setProtocol(dubboProtocol);
Invoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class,
registryUrl, new ExchangeClient[] { new MockedClient("10.20.20.20", 2222, true) });
registryProtocol.export(invoker);
}
示例4: testExportUrlNull
import com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testExportUrlNull() {
RegistryProtocol registryProtocol = new RegistryProtocol();
registryProtocol.setCluster(new FailfastCluster());
Protocol dubboProtocol = DubboProtocol.getDubboProtocol();
registryProtocol.setProtocol(dubboProtocol);
Invoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class,
registryUrl, new ExchangeClient[]{new MockedClient("10.20.20.20", 2222, true)});
registryProtocol.export(invoker);
}
示例5: refer
import com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker; //导入依赖的package包/类
public <T> Invoker<T> refer(Class<T> serviceType, URL url) throws JahhanException {
// modified by lishen
optimizeSerialization(url);
// create rpc invoker.
DubboInvoker<T> invoker = new DubboInvoker<T>(serviceType, url, getClients(url), invokers);
invokers.add(invoker);
return invoker;
}