Java-泽西岛、JAX RS

发布于 2024-11-07 17:16:03 字数 828 浏览 0 评论 0原文

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

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

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

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

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

  3. 我如何识别我实际上是否已经实现了此类 API 并知道我是否需要它们?

当我决定实现 RESTful Web 服务时,我只是按照 Netbeans 教程进行操作,向导提供了简单快速的开发时间。我知道使用向导是因为他们速度快并且能完成工作。 然而我想知道,当你接到一项编码任务时。您如何知道要使用哪些 API、框架、附加组件等。哪个版本的 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.

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.

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 is an API.
    Is an API basically a collection of libraries used to implement some form of functionality in Java?

  2. 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?

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

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.

Thanks for taking the time to read :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

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

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

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

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

  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.

  2. 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. 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.

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.

跨年 2024-11-14 17:16:03
  1. 该 API 不提供任何实现代码(即进行实际处理的具体类)。 API仅指定接口、注解、异常。可以有一些具有一些非常基本的核心行为的具体类,但仅此而已。标准 API(如 JAX-RS)的想法是为开发人员提供一些可用于编码的东西,而不管底层平台和实现

  2. Jersey 是实现 - 它包括许多实际处理承诺业务的具体类 em> 通过 API。在 JAX-RS 情况下 - 它处理请求和响应。

  3. 您通常不会实现 API。你用一个。通常 JavaEE 标准 API 使用 javax.包,而实现则使用不同的包 - com.sunorg.apache 等。如果您只使用 javax.,这是一个好兆头。 code> 接口而不是具体类。

  1. The API does not provide any implementation code (that is, concrete classes that do the actual processing). The API only specifies interfaces, annotations, exceptions. There can be concrete classes with some very basic, core behaviour, but that's all. The idea of standard APIs, like JAX-RS, is to give developers something to code against regardless of the underlying platform and implementation

  2. Jersey is the implementation - it includes many concrete classes that actually handle the business promised by the API. In JAX-RS case - it handles requests and responses.

  3. You don't usually implement an API. You use one. Normally JavaEE standard APIs use the javax. package, while implementations use a different package - com.sun, org.apache, etc. It is a good sign if you only use the javax. interfaces and not the concrete classes.

瘫痪情歌 2024-11-14 17:16:03

没有任何数学和物理知识,你就无法进行工程。花大量时间学习基础知识。如果您在开发中遇到麻烦,这些向导将无法再帮助您...

  1. JAX-RS 只是一个规范,而不是实现。实现有 Jersey、RestEasy 等。
  2. 参见 1。
  3. 只要您不编写自己的 JAX-RS 实现,您就不会实现 API。您在项目中使用它们。

without any knowledge of Mathematics and Physics, you cannot engineer. Spend much time to learn fundamentals. If you get troubles in development, these wizards won't be able to help you any more...

  1. JAX-RS is just a specification, not implementation. Implementations are Jersey, RestEasy etc.
  2. see 1.
  3. as long as you don't write your own JAX-RS implementation, you don't implement APIs. You use them in your projects.
听不够的曲调 2024-11-14 17:16:03

恕我直言,为给定任务选择正确的框架是 Java 生态系统中最困难的事情之一,因为您有大量的选择。

我的策略是首先检查一些众所周知的解决方案(apache.org 就是其中之一),然后实施小的概念验证,看看该框架是否可以足够轻松地完成这项工作。不要使用向导,它们无助于发现新的框架。或者使用它们并尝试发现它们的局限性......

The selection of the right framework for a given task is imho one of the more difficult things to do in the Java ecosystem, just because of the sheer amount of choices you have.

My strategy is to first check some well known places for solutions (apache.org is one of those) and then implement a small proof of concept to see if that framework can do the job easily enough. Do not use wizards, they do not help to discover a new framwork. Or do use them and try to discover their limits...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文