9

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 :)

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
Paddy
  • 91
  • 1
  • 5

4 Answers4

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

kamaci
  • 72,915
  • 69
  • 228
  • 366
laz
  • 28,320
  • 5
  • 53
  • 50
3
  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.

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
1

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.
Erhan Bagdemir
  • 5,231
  • 6
  • 34
  • 40
0

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

KoW
  • 784
  • 5
  • 12