Java-泽西岛,JAX RS [英] Java- Jersey, JAX RS

查看:21
本文介绍了Java-泽西岛,JAX RS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些开发 Java 程序的经验.但是,我一直难以理解一些基础知识,例如构成 Java 企业应用程序的所有不同组件.

I've some experience developing Java programs. However I have always struggled to understand some basics, such as all the different components that make up a Java Enterprise Application.

例如,我已经实现了从 J2ME 应用程序使用的基于 RESTful 和 SOAP 的 Web 服务,并为我的 MSC 执行了性能和成本测试.

For example I have implemented RESTful and SOAP based Web services that are consumed from a J2ME application and performed performance and costing tests for my MSC.

为了开发基于 RESTful/SOAP 的 Web 服务,我使用了 Netbeans 中的向导功能.它使用 JAX-RS 来实现 REST Web 服务.然后我看到其他使用 JAX-RS 和 Jersey 等的教程.我经常在 API、应用程序框架、配置文件、Java 版本等行话中迷失.这里有几个问题

To develop the RESTful/SOAP based Web services, I used the wizard functionality in Netbeans. It uses JAX-RS to implement the REST web services. Then I see other tutorials that use JAX-RS with Jersey etc. I often get lost in the jargon such as API's, application frameworks, configuration files, Java edition and so on etc. Here are a few questions

  1. JAX-RS 是一个 API.API 基本上是用于在 Java 中实现某种形式的功能的库的集合吗?

  1. JAX-RS is an API. Is an API basically a collection of libraries used to implement some form of functionality in Java?

根据他们的网站,Jersey 是用于构建 RESTful Web 服务的开源、生产质量、JAX-RS (JSR 311) 参考实现."Jersey 是另一个 API 还是与 JAX-RS 结合使用,两者之间有什么区别?

According to their site "Jersey is the open source, production quality, JAX-RS (JSR 311) Reference Implementation for building RESTful Web services." Is Jersey another API or is it used in conjunction with JAX-RS, and whats the difference between the two?

我如何识别我是否确实实现了此类 API 并知道我是否需要它们?

How do I recognise if in fact I have implemented such API's and know if I need them?

当我决定实施 RESTful Web 服务时,我只是按照 Netbeans 教程进行操作,向导提供了简单快捷的开发时间.我知道使用向导是因为它们速度快且能胜任.但是我想知道,当您被赋予编码任务时.您如何知道要使用哪些 API、框架、附加组件等.什么版本的 Java 与库等兼容.是只有我还是你有时会迷路?或者这将来自经验.

When I decided to implement RESTful web services, I just followed a Netbeans tutorial and the wizards provided easy and quick development time. I understand that wizards are used because they are quick and do the job. However I wonder, when you are given a task to code. How do you know what API's, frameworks, add-ons etc to use. What edition of Java is compliant with the libraries etc. Is it just me or do you get lost at times? Or will this come from experience.

感谢您花时间阅读:)

推荐答案

  1. JAX-RS 不仅仅是一个 API.它是一个 Java 规范请求 (JSR).这些定义了实现者必须支持的 API 和行为.如果您编写代码以使用 JSR 定义的 API,那么您可以选择在运行时使用哪个实现.

  1. JAX-RS is more than just an API. It is a Java Specification Request (JSR). Those define the API and behaviors that must be supported by an implementor. If you write your code to use the API defined by the JSR then you can choose which implementation to use at runtime.

Jersey 是提供由 JSR 311.将其称为参考实现表明它得到了 JSR 的创建者的支持,并且可能与 Oracle 的软件捆绑在一起.JSR 311 的其他实现还包括 RestletCXFRESTEasy.

Jersey is code that provides the behavior dictated by JAX-RS defined by JSR 311. Calling it the reference implementation indicates that it is supported by the creators of the JSR and is probably bundled with Oracle's software. Other implementations of JSR 311 also include Restlet, CXF, and RESTEasy.

通常,您会使用第 3 方库来实现我在上面第 2 条中提到的规范.您可能会考虑自己实现它的唯一原因是不存在合适的实现.

Typically you would use a 3rd party library that implements the specification as I mentioned in number 2 above. The only reason you might consider implementing it yourself is if a suitable implementation did not exist.

找出哪些 API 和规范可以帮助您的唯一方法实际上是通过发现过程.JSR 旨在成为为通用问题定义解决方案的常用方法,您可以在其中选择最适合您的实现.

The only way to find out what APIs and specifications can help you is through a discovery process really. JSRs are meant to be a common approach to defining a solution for a generic problem where you can choose the implementation that works best for you.

这篇关于Java-泽西岛,JAX RS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆