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


Java Result.getValue方法代码示例

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


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

示例1: invoke

import com.alibaba.dubbo.rpc.Result; //导入方法依赖的package包/类
@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
  long start = System.currentTimeMillis();
  String classDotMethod = (invocation.getInvoker().getInterface().getName().concat(".").concat(invocation
      .getMethodName()));

  try {
    Result r = invoker.invoke(invocation);
    long end = System.currentTimeMillis();
    LogBean log = new LogBean();
    log.ct = (end - start);
    log.k = (invocation.getInvoker().getInterface().getName() + "." + invocation.getMethodName());
    // provider
    log.ext = (invoker.getUrl().getAddress());
    log.t = System.currentTimeMillis();
    log.p = Arrays.toString(invocation.getArguments());
    log.r = (r != null ? r.getValue() : null);
    log.tp = LogBean.TYPE_DUBBO_PERF; // DUBBO_PERF
    dubboLogger.info(JSON.toJSONString(log));
    return r;
  } catch (Exception e) {
    logger.error("DubboServiceFilter.invoke error args : invoker={},invocation={},e={} ", invoker, invocation, e);
    throw e;
  }
}
 
开发者ID:eXcellme,项目名称:eds,代码行数:26,代码来源:DubboServiceFilter.java

示例2: testMockInvokerFromOverride_Invoke_check_ListPojo

import com.alibaba.dubbo.rpc.Result; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testMockInvokerFromOverride_Invoke_check_ListPojo(){
	URL url = URL.valueOf("remote://1.2.3.4/"+IHelloService.class.getName())
			.addParameter("getUsers.mock","force:return [{id:1, name:\"hi1\"}, {id:2, name:\"hi2\"}]")
			.addParameter("invoke_return_error", "true" );
	Invoker<IHelloService> cluster = getClusterInvoker(url);        
	//方法配置了mock
       RpcInvocation invocation = new RpcInvocation();
	invocation.setMethodName("getUsers");
       Result ret = cluster.invoke(invocation);
       List<User> rl = (List<User>)ret.getValue();
       System.out.println(rl);
       Assert.assertEquals(2, rl.size());
       Assert.assertEquals("hi1", ((User)rl.get(0)).getName());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:17,代码来源:MockClusterInvokerTest.java

示例3: encodeResponseData

import com.alibaba.dubbo.rpc.Result; //导入方法依赖的package包/类
@Override
protected void encodeResponseData(Channel channel, ObjectOutput out, Object data) throws IOException {
    Result result = (Result) data;

    Throwable th = result.getException();
    if (th == null) {
        Object ret = result.getValue();
        if (ret == null) {
            out.writeByte(RESPONSE_NULL_VALUE);
        } else {
            out.writeByte(RESPONSE_VALUE);
            out.writeObject(ret);
        }
    } else {
        out.writeByte(RESPONSE_WITH_EXCEPTION);
        out.writeObject(th);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:19,代码来源:DubboCodec.java

示例4: encodeResponseData

import com.alibaba.dubbo.rpc.Result; //导入方法依赖的package包/类
@Override
protected void encodeResponseData(Channel channel, ObjectOutput out, Object data) throws IOException {
    Result result = (Result) data;
    Throwable th = result.getException();
    if (th == null) {
        Object ret = result.getValue();
        if (ret == null) {
            out.writeByte(RESPONSE_NULL_VALUE);
        } else {
            out.writeByte(RESPONSE_VALUE);
            out.writeObject(ret);
        }
    } else {
        out.writeByte(RESPONSE_WITH_EXCEPTION);
        out.writeObject(th);
    }
    //2016-12-12张科伟 provider encode attachmend
    out.writeObject(result.getAttachments());
}
 
开发者ID:zhangkewei,项目名称:dubbo-transaction,代码行数:20,代码来源:DubboCodec.java

示例5: testMockInvokerFromOverride_Invoke_check_ListPojo

import com.alibaba.dubbo.rpc.Result; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testMockInvokerFromOverride_Invoke_check_ListPojo() {
    URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
            .addParameter("getUsers.mock", "force:return [{id:1, name:\"hi1\"}, {id:2, name:\"hi2\"}]")
            .addParameter("invoke_return_error", "true");
    Invoker<IHelloService> cluster = getClusterInvoker(url);
    //方法配置了mock
    RpcInvocation invocation = new RpcInvocation();
    invocation.setMethodName("getUsers");
    Result ret = cluster.invoke(invocation);
    List<User> rl = (List<User>) ret.getValue();
    System.out.println(rl);
    Assert.assertEquals(2, rl.size());
    Assert.assertEquals("hi1", ((User) rl.get(0)).getName());
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:17,代码来源:MockClusterInvokerTest.java

示例6: testMockInvokerFromOverride_Invoke_check_ListString

import com.alibaba.dubbo.rpc.Result; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testMockInvokerFromOverride_Invoke_check_ListString(){
	URL url = URL.valueOf("remote://1.2.3.4/"+IHelloService.class.getName())
			.addParameter("getListString.mock","force:return [\"hi\",\"hi2\"]")
			.addParameter("invoke_return_error", "true" );
	Invoker<IHelloService> cluster = getClusterInvoker(url);        
	//方法配置了mock
       RpcInvocation invocation = new RpcInvocation();
	invocation.setMethodName("getListString");
       Result ret = cluster.invoke(invocation);
       List<String> rl = (List<String>)ret.getValue();
       Assert.assertEquals(2, rl.size());
       Assert.assertEquals("hi", rl.get(0));
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:16,代码来源:MockClusterInvokerTest.java

示例7: testMockInvokerFromOverride_Invoke_check_ListString

import com.alibaba.dubbo.rpc.Result; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testMockInvokerFromOverride_Invoke_check_ListString() {
    URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
            .addParameter("getListString.mock", "force:return [\"hi\",\"hi2\"]")
            .addParameter("invoke_return_error", "true");
    Invoker<IHelloService> cluster = getClusterInvoker(url);
    //方法配置了mock
    RpcInvocation invocation = new RpcInvocation();
    invocation.setMethodName("getListString");
    Result ret = cluster.invoke(invocation);
    List<String> rl = (List<String>) ret.getValue();
    Assert.assertEquals(2, rl.size());
    Assert.assertEquals("hi", rl.get(0));
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:16,代码来源:MockClusterInvokerTest.java


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