有谁知道像 Apache CXF 为 REST 提供的 Jersey 客户端代理实现
Apache CXF 项目为 REST 服务提供基于代理的客户端实现。这看起来像:
Resource resource = JAXRSClientFactory.create( baseAddress, Resource.class )
有人知道泽西岛有类似的实现吗?
我发现了一种使用 @HyperMediaController
注释的方法,但我想坚持使用 JSR-311 默认注释,例如 @Path
和 @Get
...
有人有想法吗?
the Apache CXF project offers a proxy based client implementation for REST services. This looks like:
Resource resource = JAXRSClientFactory.create( baseAddress, Resource.class )
Does anyone know a similar implementation for Jersey?
I spotted an approach using @HyperMediaController
annotations, but I want to stick to JSR-311 default annotations like @Path
and @Get
...
Has anyone an idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
存在代理实现,但不幸的是 Jersey Client API 文档 中甚至没有提及它(自版本 2.22.1 起,Jersey 用户指南中均未包含此内容。
我发现的是 WebResourceFactory,更好的是 包 JavaDoc。以下是 JavaDoc 中有关 WebResourceFactory 用法的片段:
在 Maven 中,您还需要
:
A proxy implementation exists, but unfortunately it's not even mentioned in Jersey Client API documentation (neither in Jersey User Guide) as of version 2.22.1.
What I found was JavaDoc for WebResourceFactory, even better is the package JavaDoc. Here's a snippet from the JavaDoc on the usage of the WebResourceFactory:
In Maven you then need:
in addition to
我发现 WebResourceFactory 缺少泛型类型支持,而且它的源代码真的很难理解。因此我们创建了 https://github.com/adaptris/jaxrs-client-proxy 并我们目前正在开发它。
要使用它,您需要构建一个资源:
然后您可以调用
client
- 这是您的 jax-rs 注释描述的接口(Resource.class
)的代理。按照 jax-rs 客户端 api 的建议,您应该在停止使用资源后将其关闭。更多详细信息请参见 github projet 页面。
I found WebResourceFactory miss generic types supports and it's source code was really hard to understand. So we created https://github.com/adaptris/jaxrs-client-proxy and we are currently devloping it.
To use it you need to build a resource:
Then you can call
client
- which is proxy of your jax-rs annotation described interface (Resource.class
). You should close a resource after stoping using it as it is recommended by jax-rs client api.More details on github projet page.
我创建了一个自己的实现。请参阅 utils-apl-衍生 Wiki 页面。
I created an own implementation. See utils-apl-derived wiki page therefore.