Package com.alibaba.dubbo.rpc

Examples of com.alibaba.dubbo.rpc.RpcResult


                    if (serviceFile == null || exceptionFile == null || serviceFile.equals(exceptionFile)){
                        return result;
                    }
                    //除上面二种情况外,server端打印日志,并包装成runtimeException抛给客户端
                    logger.error("Got unchecked and undeclare service method invoke exception: " + exception.getMessage(), exception);
                    return new RpcResult(new RuntimeException(StringUtils.toString(exception)));
                } catch (Throwable e) {
                    logger.warn(e.getMessage(), e);
                    return result;
                }
            }
View Full Code Here


      if (StringUtils.isBlank(mock)){
        throw new RpcException(new IllegalAccessException("mock can not be null. url :" + url));
      }
        mock = normallizeMock(URL.decode(mock));
        if (Constants.RETURN_PREFIX.trim().equalsIgnoreCase(mock.trim())){
          RpcResult result = new RpcResult();
          result.setValue(null);
          return result;
        } else if (mock.startsWith(Constants.RETURN_PREFIX)) {
            mock = mock.substring(Constants.RETURN_PREFIX.length()).trim();
            mock = mock.replace('`', '"');
            try {
                Type[] returnTypes = RpcUtils.getReturnTypes(invocation);
                Object value = parseMockValue(mock, returnTypes);
                return new RpcResult(value);
            } catch (Exception ew) {
              throw new RpcException("mock return invoke error .invocation :" + invocation + ", mock:" + mock + ", url: "+ url , ew);
            }
        } else if (mock.startsWith(Constants.THROW_PREFIX)) {
          mock = mock.substring(Constants.THROW_PREFIX.length()).trim();
View Full Code Here

    public void destroy() {
    }

    public Result invoke(Invocation invocation) throws RpcException {
        try {
            return new RpcResult(doInvoke(proxy, invocation.getMethodName(), invocation.getParameterTypes(), invocation.getArguments()));
        } catch (InvocationTargetException e) {
            return new RpcResult(e.getTargetException());
        } catch (Throwable e) {
            throw new RpcException("Failed to invoke remote proxy " + invocation + " to " + getUrl() + ", cause: " + e.getMessage(), e);
        }
    }
View Full Code Here

                } else {
                    boolean isSent = getUrl().getMethodParameter(methodName, Constants.SENT_KEY, false);
                    currentClient.send(inv, isSent);
                    RpcContext.getContext().setFuture(null);
                }
                return new RpcResult();
            }
            RpcContext.getContext().setFuture(null);
            return (Result) currentClient.request(inv, timeout).get();
        } catch (TimeoutException e) {
            throw new RpcException(RpcException.TIMEOUT_EXCEPTION, "Failed to invoke remote invocation " + invocation + " to " + getUrl() + ", cause: " + e.getMessage(), e);
View Full Code Here

            return invoker.invoke(invocation);
        } catch (Throwable e) {
            logger.error("Failback to invoke " + invocation + ", wait for retry in background. Ignored exception: "
                                 + e.getMessage() + ", ", e);
            addFailed(invocation, this);
            return new RpcResult(); // ignore
        }
    }
View Full Code Here

            } else {
                throw new RpcException( "There is no merger to merge result." );
            }
        }

        return new RpcResult( result );
    }
View Full Code Here

    }
    try {
      result = minvoker.invoke(invocation);
    } catch (RpcException me) {
      if (me.isBiz()) {
        result = new RpcResult(me.getCause());
      } else {
        throw new RpcException(me.getCode(), getMockExceptionMessage(e, me), me.getCause());
      }
//     
    } catch (Throwable me) {
View Full Code Here

            if (cache != null) {
                String key = StringUtils.toArgumentString(invocation.getArguments());
                if (cache != null && key != null) {
                    Object value = cache.get(key);
                    if (value != null) {
                        return new RpcResult(value);
                    }
                    Result result = invoker.invoke(invocation);
                    if (! result.hasException()) {
                        cache.put(key, result.getValue());
                    }
View Full Code Here

      if (StringUtils.isBlank(mock)){
        throw new RpcException(new IllegalAccessException("mock can not be null. url :" + url));
      }
        mock = normallizeMock(URL.decode(mock));
        if (Constants.RETURN_PREFIX.trim().equalsIgnoreCase(mock.trim())){
          RpcResult result = new RpcResult();
          result.setValue(null);
          return result;
        } else if (mock.startsWith(Constants.RETURN_PREFIX)) {
            mock = mock.substring(Constants.RETURN_PREFIX.length()).trim();
            mock = mock.replace('`', '"');
            try {
                Type[] returnTypes = RpcUtils.getReturnTypes(invocation);
                Object value = parseMockValue(mock, returnTypes);
                return new RpcResult(value);
            } catch (Exception ew) {
              throw new RpcException("mock return invoke error. method:" + invocation.getMethodName() + ", mock:" + mock + ", url: "+ url , ew);
            }
        } else if (mock.startsWith(Constants.THROW_PREFIX)) {
          mock = mock.substring(Constants.THROW_PREFIX.length()).trim();
View Full Code Here

                } else {
                    boolean isSent = getUrl().getMethodParameter(methodName, Constants.SENT_KEY, false);
                    currentClient.send(inv, isSent);
                    RpcContext.getContext().setFuture(null);
                }
                return new RpcResult();
            }
            RpcContext.getContext().setFuture(null);
            return (Result) currentClient.request(inv, timeout).get();
        } catch (TimeoutException e) {
            throw new RpcException(RpcException.TIMEOUT_EXCEPTION, "Invoke remote method timeout. method: " + invocation.getMethodName() + ", provider: " + getUrl() + ", cause: " + e.getMessage(), e);
View Full Code Here

TOP

Related Classes of com.alibaba.dubbo.rpc.RpcResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.