users@jsr311.java.net

Re: Dealing with Matrix parameters

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Mon, 24 Nov 2008 10:41:58 -0500

On Nov 24, 2008, at 6:57 AM, Sergey Beryozkin wrote:
>
> The method :
>
> @GET
> @Path("{base}/{tail}")
> public String getFirstResource(@PathParam("base") String base,
> @PathParam("tail")
> String tail,
>
> @MatrixParam("matrixParam") String matrixParm) {}
>
> 1. GET /base/beginTail;matrixParam=ParamValue
>
> The value for (@PathParam("tail") String) tail is
> "beginTail;matrixParam=ParamValue", but a user expectes only
> "beginTail".
>
It should be "beginTail".

>
> 2. GET /base;matrixParam=ParamValue/beginTail
>
> The value of (@MatrixParam("matrixParam") String) matrixParam is
> null which is most likely a CXF mistake I believe but I'd like to
> confirm : should all path segments (like {base} and {tail}) be
> checked for sa given matrix parameter or only the last parameterized
> segment ? For ex
>
> @Path("{base}/{tail}") - only {tail} one is checked
> @Path("base/{tail}") - only {tail} one is checked
> @Path("{base}/tail") - only {base} one is checked
> ?
>
All path segments are checked and the first value (lexically) of the
parameter is used. You can get all values using a List, Set or
SortedSet type.

> 3. The above method gets changed like this :
>
> @GET
> @Path("base/{tail}")
> public String getFirstResource(@PathParam("tail") String tail,
>
> @MatrixParam("matrixParam") String matrixParm) {}
>
> as a result
>
> GET /base;matrixParam=ParamValue/beginTail
>
> does not match the method.
>
> I think it's correct, 'base' is not capturing anymore and hence an
> exact match is required
>
Matrix parameters are ignored for matching purposes so it should still
match.

Marc.

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.