users@jersey.java.net

Question to correct URI-mapping behaviour

From: Daniel Bimschas <daniel_at_bimschas.com>
Date: Wed, 27 Jan 2010 16:59:54 +0100

Hi list!

I have a question regarding the correct mapping of URIs to JAX-RS methods. We have an implementation class that provides two methods as follows:

  @GET
  @Path("abc/{var}")
  public Response getAbc(@PathParam("var") var) { ... }

  @GET
  @Path("abc/{var}.xml")
  public Response getAbcAsXML(@PathParam("var") var) { ... }

The JAX-RS specification says in 3.7.2 Request Matching under "3. Identify the method that will handle the request":

  "(c) The request is dispatched to the first Java method in the set5."

While a set has no order this seems to be implementation dependent and/or "non-deterministic". Is this correct?

As I suppose both methods are valid candidates for the set mentioned in the spec I wonder which method should be chosen. The problem (which is why I ask) is that Jersey choses getAbc(...) while the Apache CXF implementation choses getAbcAsXML(...) obviously interpreting the "something.xml" in the URI as the value for the path parameter. Is there a way to tell which behaviour is correct? Has one of the implementations a bug?

Kind regards,
Daniel