当前位置: 首页>>代码示例>>Java>>正文


Java ProxyFactory.getProxy方法代码示例

本文整理汇总了Java中com.alibaba.dubbo.rpc.ProxyFactory.getProxy方法的典型用法代码示例。如果您正苦于以下问题:Java ProxyFactory.getProxy方法的具体用法?Java ProxyFactory.getProxy怎么用?Java ProxyFactory.getProxy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.dubbo.rpc.ProxyFactory的用法示例。


在下文中一共展示了ProxyFactory.getProxy方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testHessianProtocol

import com.alibaba.dubbo.rpc.ProxyFactory; //导入方法依赖的package包/类
@Test
public void testHessianProtocol() {
    HessianServiceImpl server = new HessianServiceImpl();
    Assert.assertFalse(server.isCalled());
    ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
    Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
    URL url = URL.valueOf("hessian://127.0.0.1:5342/" + HessianService.class.getName() + "?version=1.0.0");
    Exporter<HessianService> exporter = protocol.export(proxyFactory.getInvoker(server, HessianService.class, url));
    Invoker<HessianService> invoker = protocol.refer(HessianService.class, url);
    HessianService client = proxyFactory.getProxy(invoker);
    String result = client.sayHello("haha");
    Assert.assertTrue(server.isCalled());
    Assert.assertEquals("Hello, haha", result);
    invoker.destroy();
    exporter.unexport();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:17,代码来源:HessianProtocolTest.java

示例2: testHttpClient

import com.alibaba.dubbo.rpc.ProxyFactory; //导入方法依赖的package包/类
@Test
public void testHttpClient() {
    HessianServiceImpl server = new HessianServiceImpl();
    Assert.assertFalse(server.isCalled());
    ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
    Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
    URL url = URL.valueOf("hessian://127.0.0.1:5342/" + HessianService.class.getName() + "?version=1.0.0&client=httpclient");
    Exporter<HessianService> exporter = protocol.export(proxyFactory.getInvoker(server, HessianService.class, url));
    Invoker<HessianService> invoker = protocol.refer(HessianService.class, url);
    HessianService client = proxyFactory.getProxy(invoker);
    String result = client.sayHello("haha");
    Assert.assertTrue(server.isCalled());
    Assert.assertEquals("Hello, haha", result);
    invoker.destroy();
    exporter.unexport();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:17,代码来源:HessianProtocolTest.java

示例3: testTimeOut

import com.alibaba.dubbo.rpc.ProxyFactory; //导入方法依赖的package包/类
@Test
public void testTimeOut() {
    HessianServiceImpl server = new HessianServiceImpl();
    ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
    Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
    URL url = URL.valueOf("hessian://127.0.0.1:5342/" + HessianService.class.getName() + "?version=1.0.0&timeout=10");
    Exporter<HessianService> exporter = protocol.export(proxyFactory.getInvoker(server, HessianService.class, url));
    Invoker<HessianService> invoker = protocol.refer(HessianService.class, url);
    HessianService client = proxyFactory.getProxy(invoker);
    try {
        client.timeOut(6000);
        fail();
    } catch (RpcException expected) {
        Assert.assertEquals(true, expected.isTimeout());
    }finally{
        invoker.destroy();
        exporter.unexport();
    }
    
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:21,代码来源:HessianProtocolTest.java

示例4: testCustomException

import com.alibaba.dubbo.rpc.ProxyFactory; //导入方法依赖的package包/类
@Test
public void testCustomException() {
    HessianServiceImpl server = new HessianServiceImpl();
    ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
    Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
    URL url = URL.valueOf("hessian://127.0.0.1:5342/" + HessianService.class.getName() + "?version=1.0.0");
    Exporter<HessianService> exporter = protocol.export(proxyFactory.getInvoker(server, HessianService.class, url));
    Invoker<HessianService> invoker = protocol.refer(HessianService.class, url);
    HessianService client = proxyFactory.getProxy(invoker);
    try {
        client.customException();
        fail();
    } catch (MyException expected) {
    }
    invoker.destroy();
    exporter.unexport();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:18,代码来源:HessianProtocolTest.java

示例5: testRestProtocol

import com.alibaba.dubbo.rpc.ProxyFactory; //导入方法依赖的package包/类
@Test
public void testRestProtocol() throws InterruptedException {
    RestService server = new RestServiceImpl();
    ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
    Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
    URL url = URL.valueOf("resteasy://127.0.0.1:5342/" + RestService.class.getName() + "?version=1.0.0&logger=slf4j");
    ServiceClassHolder.getInstance().pushServiceClass(RestService.class);
    Exporter<RestService> exporter = protocol.export(proxyFactory.getInvoker(server, RestService.class, url));
    Invoker<RestService> invoker = protocol.refer(RestService.class, url);
    RestService client = proxyFactory.getProxy(invoker);
    RequestDto requestDto = new RequestDto();
    requestDto.setAge(88);
    requestDto.setName("doctor who");
    ModelResult<String> modelResult = client.test(requestDto);

    String expected = "test " + ToStringBuilder.reflectionToString(requestDto, ToStringStyle.SHORT_PREFIX_STYLE);
    System.out.println(expected);
    Assert.assertEquals(expected, modelResult.getData());
    invoker.destroy();

    // TimeUnit.MINUTES.sleep(1);
    exporter.unexport();
}
 
开发者ID:sdcuike,项目名称:dubbo-rpc-rest,代码行数:24,代码来源:RestProtocolTest.java

示例6: testJsonrpcProtocol

import com.alibaba.dubbo.rpc.ProxyFactory; //导入方法依赖的package包/类
@Test
public void testJsonrpcProtocol() {
    JsonRpcServiceImpl server = new JsonRpcServiceImpl();
    Assert.assertFalse(server.isCalled());
    ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
    Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
    URL url = URL.valueOf("jsonrpc://127.0.0.1:5342/" + JsonRpcService.class.getName() + "?version=1.0.0");
    Exporter<JsonRpcService> exporter = protocol.export(proxyFactory.getInvoker(server, JsonRpcService.class, url));
    Invoker<JsonRpcService> invoker = protocol.refer(JsonRpcService.class, url);
    JsonRpcService client = proxyFactory.getProxy(invoker);
    String result = client.sayHello("haha");
    Assert.assertTrue(server.isCalled());
    Assert.assertEquals("Hello, haha", result);
    invoker.destroy();
    exporter.unexport();
}
 
开发者ID:dubbo,项目名称:dubbo-rpc-jsonrpc,代码行数:17,代码来源:JsonRpcProtocolTest.java

示例7: testJsonrpcProtocolForServerJetty9

import com.alibaba.dubbo.rpc.ProxyFactory; //导入方法依赖的package包/类
@Test
public void testJsonrpcProtocolForServerJetty9() {
    JsonRpcServiceImpl server = new JsonRpcServiceImpl();
    Assert.assertFalse(server.isCalled());
    ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
    Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
    URL url = URL.valueOf("jsonrpc://127.0.0.1:5342/" + JsonRpcService.class.getName() + "?version=1.0.0&server=jetty9");
    Exporter<JsonRpcService> exporter = protocol.export(proxyFactory.getInvoker(server, JsonRpcService.class, url));
    Invoker<JsonRpcService> invoker = protocol.refer(JsonRpcService.class, url);
    JsonRpcService client = proxyFactory.getProxy(invoker);
    String result = client.sayHello("haha");
    Assert.assertTrue(server.isCalled());
    Assert.assertEquals("Hello, haha", result);
    invoker.destroy();
    exporter.unexport();
}
 
开发者ID:dubbo,项目名称:dubbo-rpc-jsonrpc,代码行数:17,代码来源:JsonRpcProtocolTest.java

示例8: testCustomException

import com.alibaba.dubbo.rpc.ProxyFactory; //导入方法依赖的package包/类
@Test
@Ignore
public void testCustomException() {
    JsonRpcServiceImpl server = new JsonRpcServiceImpl();
    ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
    Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
    URL url = URL.valueOf("jsonrpc://127.0.0.1:5342/" +
            JsonRpcService.class.getName() + "?version=1.0.0&server=jetty9");
    Exporter<JsonRpcService> exporter = protocol.export(proxyFactory.getInvoker(server, JsonRpcService.class, url));
    Invoker<JsonRpcService> invoker = protocol.refer(JsonRpcService.class, url);
    JsonRpcService client = proxyFactory.getProxy(invoker);
    try {
        client.customException();
        Assert.fail();
    } catch (JsonRpcServiceImpl.MyException expected) {
    }
    invoker.destroy();
    exporter.unexport();
}
 
开发者ID:dubbo,项目名称:dubbo-rpc-jsonrpc,代码行数:20,代码来源:JsonRpcProtocolTest.java

示例9: testTimeOut

import com.alibaba.dubbo.rpc.ProxyFactory; //导入方法依赖的package包/类
@Test
public void testTimeOut() {
    HessianServiceImpl server = new HessianServiceImpl();
    ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
    Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
    URL url = URL.valueOf("hessian://127.0.0.1:5342/" + HessianService.class.getName() + "?version=1.0.0&timeout=10");
    Exporter<HessianService> exporter = protocol.export(proxyFactory.getInvoker(server, HessianService.class, url));
    Invoker<HessianService> invoker = protocol.refer(HessianService.class, url);
    HessianService client = proxyFactory.getProxy(invoker);
    try {
        client.timeOut(6000);
        fail();
    } catch (RpcException expected) {
        Assert.assertEquals(true, expected.isTimeout());
    } finally {
        invoker.destroy();
        exporter.unexport();
    }

}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:21,代码来源:HessianProtocolTest.java


注:本文中的com.alibaba.dubbo.rpc.ProxyFactory.getProxy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。