gpt4 book ai didi

com.weibo.yar.YarRequest类的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 08:19:31 26 4
gpt4 key购买 nike

本文整理了Java中com.weibo.yar.YarRequest类的一些代码示例,展示了YarRequest类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YarRequest类的具体详情如下:
包路径:com.weibo.yar.YarRequest
类名称:YarRequest

YarRequest介绍

暂无

代码示例

代码示例来源:origin: weibocom/motan

public static YarRequest convert(Request request, String packagerName) {
  YarRequest yarRequest = new YarRequest();
  yarRequest.setId(request.getRequestId());
  yarRequest.setMethodName(request.getMethodName());
  yarRequest.setPackagerName(packagerName);
  yarRequest.setParameters(request.getArguments());
  return yarRequest;
}

代码示例来源:origin: weibocom/motan

public AttachmentRequest(YarRequest yarRequest, Map<String, String> attachments) {
  this(yarRequest.getId(), yarRequest.getPackagerName(), yarRequest.getMethodName(), yarRequest.getParameters());
  this.attachments = attachments;
}

代码示例来源:origin: weibocom/motan

@Override
public Object handle(Channel channel, Object message) {
  YarRequest yarRequest = (YarRequest) message;
  String packagerName = yarRequest.getPackagerName();
  Provider<?> provider = providerMap.get(yarRequest.getRequestPath());
  if (provider == null) {
    throw new MotanServiceException("can not find service provider. request path:" + yarRequest.getRequestPath());
  }
  Class<?> clazz = provider.getInterface();
  Request request = YarProtocolUtil.convert(yarRequest, clazz);
  Response response = call(request, provider);
  YarResponse yarResponse = YarProtocolUtil.convert(response, packagerName);
  return yarResponse;
}

代码示例来源:origin: weibocom/motan

/**
 * convert yar request to motan rpc request
 * 
 * @param yarRequest
 * @param interfaceClass
 * @return
 */
public static Request convert(YarRequest yarRequest, Class<?> interfaceClass) {
  DefaultRequest request = new DefaultRequest();
  request.setInterfaceName(interfaceClass.getName());
  request.setMethodName(yarRequest.getMethodName());
  request.setRequestId(yarRequest.getId());
  addArguments(request, interfaceClass, yarRequest.getMethodName(), yarRequest.getParameters());
  if (yarRequest instanceof AttachmentRequest) {
    request.setAttachments(((AttachmentRequest) yarRequest).getAttachments());
  }
  return request;
}

代码示例来源:origin: com.weibo/yar-java

private YarResponse process(YarRequest request) {
  YarResponse response = new YarResponse();
  response.setId(request.getId());
  response.setPackagerName(request.getPackagerName());
  JSONObject jo = new JSONObject();
  jo.put("key", "test");
  response.setRet(jo);
  return response;
}

代码示例来源:origin: com.weibo/yar-java

protected byte[] buildRequestBtyes(long id, String path, String method, String packageName, Object... parameterObject)
    throws IOException {
  YarRequest yarRequest = new YarRequest(id, packageName, method, parameterObject);
  return YarProtocol.toProtocolBytes(yarRequest);
}

代码示例来源:origin: com.weibo/yar-java

@SuppressWarnings("rawtypes")
public static YarRequest buildRequest(byte[] requestBytes) throws IOException {
  if (requestBytes == null) {
    throw new YarException("request bytes is null");
  }
  Map contentMap = fetchContent(requestBytes);
  YarRequest request = new YarRequest();
  if (contentMap.containsKey("i")) {
    request.setId(((Number) contentMap.get("i")).longValue());
  }
  request.setPackagerName((String) contentMap.get("ext-packagerName"));
  if (contentMap.containsKey("m")) {
    request.setMethodName((contentMap.get("m").toString()));
  }
  if (contentMap.containsKey("p")) {
    Object value = contentMap.get("p");
    if ((value instanceof List)) {
      request.setParameters(((List) value).toArray());
    } else if (value instanceof Map) {
      request.setParameters(((Map) value).values().toArray());
    }
  }
  return request;
}

代码示例来源:origin: com.weibo/yar-java

public static byte[] toProtocolBytes(YarRequest request) throws IOException {
  if (request == null) {
    throw new YarException("YarRequest is null");
  }
  Map<String, Object> requestMap = new HashMap<String, Object>();
  requestMap.put("i", request.getId());
  requestMap.put("m", request.getMethodName());
  requestMap.put("p", Arrays.asList(request.getParameters()));
  String packagerName = request.getPackagerName();
  return toProtocolBytes(request.getId(), packagerName, requestMap);
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com