com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker Java Examples

The following examples show how to use com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RegistryProtocolTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@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);
    //The same invoker, exporter that multiple exported are different
    Assert.assertNotSame(exporter, exporter2);
    exporter.unexport();
    exporter2.unexport();

}
 
Example #2
Source File: RegistryProtocolTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@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();
    
}
 
Example #3
Source File: RegistryProtocolTest.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
@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();
    
}
 
Example #4
Source File: RegistryProtocolTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@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();
    
}
 
Example #5
Source File: RegistryProtocolTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@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();
    
}
 
Example #6
Source File: RegistryProtocolTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #7
Source File: DubboUtil.java    From DevToolBox with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 调用方法
 *
 * @param c
 * @param method
 * @param fullUrl
 * @param args
 * @return
 * @throws java.lang.Exception
 */
public static Object invoke(Class c, Method method, String fullUrl, Object... args) throws Exception {
    DubboInvoker<?> invoker = (DubboInvoker<?>) PROTOCOL.refer(c, URL.valueOf(fullUrl));
    if (invoker.isAvailable()) {
        Invocation inv = new RpcInvocation(method, args);
        Result ret = invoker.invoke(inv);
        PROTOCOL.destroy();
        return JSON.json(ret.getValue());
    }
    return null;
}
 
Example #8
Source File: RegistryProtocolTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #9
Source File: RegistryProtocolTest.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #10
Source File: RegistryProtocolTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #11
Source File: RegistryProtocolTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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);
}