Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add restful protocol support by integrate jboss resteasy and testcase #458

Merged
merged 6 commits into from
Jul 10, 2017

Conversation

zhouit
Copy link
Contributor

@zhouit zhouit commented Jun 11, 2017

添加restful协议支持

  1. 支持rpc单独进程和部署到servlet容器中
  2. 支持原有服务治理功能(非motan client时不支持服务发现、负载均衡等功能)
  3. 支持rpc request/response的attachment机制
  4. 完全支持motan rpc filter机制
  5. rest服务编程完全按照JAX-RS代码方式编写

@rayzhang0603
Copy link
Collaborator

非常赞~我们尽快review 测试。

@m11y
Copy link
Contributor

m11y commented Jun 15, 2017

@dongfangshangren 我正在开发 RESTful 的支持(进度约 70%),也是基于 Resteasy, 不过容器我选用的
Undertow, 被你抢先异步发 PR 了,那我就不继续开发了,你看看有没有哪些模块可以分出来的,我可以帮着做。

@rayzhang0603 麻烦在开发者文档中标注一下 Language Level ,不然有些特性不敢用(比如 multi catch)。

@zhouit
Copy link
Contributor Author

zhouit commented Jun 15, 2017

@smartwjw 要支持undertow、vertx,sunhttp参照NettyEndpointFactory继承AbstractEndpointFactory即可,由于Undertow并未实现EmbeddedJaxrsServer 需要继承RestServer。即可完成对undertow、vertx、sunhttp的支持

另外pom文件maven-compiler-plugin已经指定target,source级别

@rayzhang0603
Copy link
Collaborator

@smartwjw 目前pom中指定编译级别为1.6,后续会考虑升到1.7

@m11y
Copy link
Contributor

m11y commented Jun 26, 2017

@dongfangshangren 我在你的代码基础上增加了对 Undertow 的支持,不过我无法编辑这个 PR, 所以给你 fork 出来的仓库发 PR 了, 请帮忙 review.


return resp.getValue();
}catch(Exception e){
Throwable cause = e.getCause();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provider在invoke时会把业务逻辑中抛出的异常转换为MotanBizException,在client端会对MotanBizException做单独处理,MotanBizException中封装的原始异常会在client端代码中抛出。因此这里还请改成直接抛出异常,这样client端端行为可以与其他协议保持一致。
建议改成:

 if (e instanceof RuntimeException) {
      throw (RuntimeException) e;
    }
    throw new InternalServerErrorException("provider call process error:" + e.getMessage(), e);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@rayzhang0603
Copy link
Collaborator

其他没有发现什么问题,测试正常。
@qdaxb 帮忙在给看看?

public Response toResponse(Exception exception){
HttpRequest httpRequest = ResteasyProviderFactory.getContextData(HttpRequest.class);
// 当为rpc调用时,序列化异常
if(httpRequest != null & RestfulUtil.isRpcRequest(httpRequest.getMutableHeaders())){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (t != null & RestfulUtil.isRpcRequest(httpRequest.getMutableHeaders())){
   ...
}

应该是 t != null && RestfulUtil.isRpcRequest(httpRequest.getMutableHeaders())

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里还请把& 改成 &&,单&符所有条件语句都会执行的。 @dongfangshangren

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

手误,已修改

@qdaxb
Copy link
Collaborator

qdaxb commented Jul 4, 2017

代码中的tab需要替换成4个空格。

@rayzhang0603 rayzhang0603 merged commit 1801fc6 into weibocom:master Jul 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants