13

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

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
user1679378
  • 1,370
  • 3
  • 17
  • 23
  • 1
    Your last question is a duplicate [of this question](http://stackoverflow.com/questions/5579744/what-is-the-difference-between-pathparam-and-queryparam). – Joachim Sauer Sep 18 '12 at 07:55
  • 6
    Try to avoid asking two questions per “question” as it encourages incoherent answers; the `@PathParam` vs. `@QueryParam` question is really another question entirely. – Donal Fellows Sep 18 '12 at 12:59

4 Answers4

22

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.

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
8

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)

NamingException
  • 2,388
  • 1
  • 19
  • 41
7

JAX-RS is a set of interfaces and classes without real implementation that belong to javax.ws.rs.* packages (they are part of Java SE 6, by Oracle).

RESTEasy as well as, for example, Jersey or Apache CXF, are open source implementations of that JAX-RS classes.

During compilation you need only JAX-RS. In runtime you need only one of that implementations.

yegor256
  • 102,010
  • 123
  • 446
  • 597
1

Please also note that JAX-RS is only server side specification and RESTEasy has extended it to bring JAX-RS to the client side through the RESTEasy JAX-RS Client Framework.

Info on param, What is the difference between @PathParam and @QueryParam Some great points here regarding params, When to use @QueryParam vs @PathParam - Gareth's answer

Community
  • 1
  • 1
abpan
  • 111
  • 5