什么是 JAX-RS 实现?
我已经尝试弄清楚如何使用 JAX-RS 有一段时间了。我从非常基本的概念开始,然后逐渐了解注解式编程,@Path
、@Get
、@Post
的含义, 据我了解,正如
很多地方提到的那样,JAX-RS是一个专注于将Java注释应用于普通Java对象的框架(第27页,Bill Burke,RESTful Java)。
超出这一点我就感到困惑了。如果 JAX-RS 本身是一个定义处理注释的 API 来实现 RESTful Web 服务的框架,那么“JAX-RS 的实现”的含义是什么,例如 "泽西" 和 "JBoss Resteasy" 。 JAX-RS 之上的另一层?为什么我们需要它们?
有人可以向我提供一些有关它的见解吗?非常感谢!
I have been trying to figure out how to use JAX-RS for quite some time. I started from the very basic concepts and then to gradually understand the annotation styled programming, the meaning of @Path
, @Get
, @Post
, etc.
To my understanding, as to what has been mentioned in a lot of places, JAX-RS is a framework that focuses on applying Java annotations to plain Java objects (Page 27, Bill Burke, RESTful Java).
I have then got confused beyond this point. If JAX-RS in itself is a framework that defines APIs dealing with annotations in order to implement RESTful web service, what's the meaning of "implementation of JAX-RS" such as "Jersey" and "JBoss Resteasy". Another layer on top of JAX-RS? Why do we need them?
Could someone provide me some insights about it? Many thanks!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
JAX-RS 是 Java 规范请求 311 (JSR-311) 中定义的标准Jersey / RESTEasy 是它的实现。
作为实现意味着规范说“如果您将
@GET("/foo")
放在方法 (bar()
) 上,您就可以访问数据 X” - 现在在应用程序服务器中,有人需要进入并实际读取您部署的代码,使用@GET
注释解析字节码,然后如果用户实际浏览到例如 http://localhost/foo 获取此 Web 请求以到达bar()
并转换bar() 的返回值
转换为 http 答案(例如,以 XML 或 JSON 表示形式)。因此,名为“JAX-RS”的规范仅提供了 @GET 等语法和语义,但解析请求、调用正确方法、编组结果值等工作需要由实现规格
该标准 2.0 版的工作已开始,名为 JRS-339。
另请参阅http://en.wikipedia.org/wiki/Jax-rs
JAX-RS is a standard defined in Java Specification Request 311 (JSR-311) and Jersey / RESTEasy are implementations of it.
Being implementations mean that the spec says "if you put
@GET("/foo")
on a method (bar()
), you may access data X" - now in an app server, someone needs to go in and actually read your deployed code, parse the byte code with the@GET
annotation and then if the user actually browses to e.g. http://localhost/foo get this web request to reachbar()
and translate the return value ofbar()
into a http answer (e.g in XML or JSON representation).So the spec with the name "JAX-RS" only provides the syntax and semantics of e.g. @GET, but the work of parsing requests, calling the right methods, marshalling the result values etc. need to be done by a package that implements the Spec.
Work on the version 2.0 of the standard has started as JRS-339.
See also http://en.wikipedia.org/wiki/Jax-rs
JAX-RS 是使用 Java 的 RESTful Web 服务的规范。 Java EE 中包含一个参考实现,但由于它是一个规范,因此可以编写其他框架来实现该规范,其中包括 Jersey、Resteasy 等。
JAX-RS is a specification for RESTful Web Services with Java. There is a reference implementation that is included in Java EE but since it is a specification, other frameworks can be written to implement the spec, and that includes Jersey, Resteasy, and others.