Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between RESTEasy and JAX-RS

What is Resteasy? what is the difference between RESTEasy and JAX-RS? What is the difference between @PathParam and @QueryParam?

like image 714
user1679378 Avatar asked Sep 18 '12 07:09

user1679378


People also ask

What is RESTEasy in JAX-RS?

Overview. JAX-RS, JSR-311, is a new JCP specification that provides a Java API for RESTful Web Services over the HTTP protocol. Resteasy is an portable implementation of this specification which can run in any Servlet container.

What is the difference between JAX-RS and spring REST?

JAX-RS is only a specification and it needs a compatible implementation to be used. On the other hand, Spring MVC is a complete framework with REST capabilities. Like JAX-RS, it also provides us with useful annotations to abstract from low-level details.

What is difference between RESTEasy and Jersey?

Both Jersey and RESTEasy provide their own implementation. The difference is that Jersey additionally provides something called Chunked Output. It allows the server to send back to the client a response in parts (chunks).

What is the difference between JAX-RS and JAX WS?

Actually,JAX-WS represents both RESTful and SOAP based web services. One way to think about it is that JAX-RS specializes in RESTful, while JAX-WS allows you more flexibility to choose between either, while at the same time being (in some cases) more complicated to configure. Thank you for simple explanation.


2 Answers

According to its homepage RESTEasy is

... a fully certified and portable implementation of the JAX-RS specification.

So JAX-RS is a specification of how a library for implementing REST APIs in Java should look like and RESTEasy is one implementation of that specification.

This effectively means that any documentation on JAX-RS should apply 1:1 to RESTEasy as well.

like image 168
Joachim Sauer Avatar answered Sep 27 '22 17:09

Joachim Sauer


Query parameters are extracted from the request URI query parameters, and are specified by using the javax.ws.rs.QueryParam annotation in the method parameter arguments.

Example:

@Path("smooth")
@GET
public Response smooth(
    @DefaultValue("2") @QueryParam("step") int step,
    @QueryParam("minm") boolean hasMin,
    @QueryParam("test") String test
    ) { ... }

URL: http://domain:port/context/XXX/smooth?step=1&minm=true&test=value

URI path parameters are extracted from the request URI, and the parameter names correspond to the URI path template variable names specified in the @Path class-level annotation. URI parameters are specified using the javax.ws.rs.PathParam annotation in the method parameter arguments

Example:

@Path("/{userName}")
public class MyResourceBean {
...
@GET
public String printUserName(@PathParam("userName") String userId) {
    ...
}
}


 URL: http://domain:port/context/XXX/naveen

Here, naveen takes as the userName(Path parameter)

like image 38
Naveenkumar K Avatar answered Sep 27 '22 16:09

Naveenkumar K