users@jsr311.java.net

Re: Dealing with Matrix parameters

From: Stephan Koops <Stephan.Koops_at_web.de>
Date: Mon, 24 Nov 2008 13:34:28 +0100

> 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".
He is right.

Instead a user could've used PathSegment
> as a 'tail' type in which case PathSegment.getPath() would return
> just 'beginTail'.
> Is it correct ?
Right. The matrix parameters are available via PathSegment.getMatrixParameters()

> 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
> ?
I think all matrix parameters are checked, but I'm not sure. Marc?

> 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.
The method matches the request, because the matching of @Path(...) ignores the matrix parameters.
_________________________________________________________________________
Sensationsangebot nur bis 30.11: WEB.DE FreeDSL - Telefonanschluss + DSL
für nur 16,37 Euro/mtl.!* http://dsl.web.de/?ac=OM.AD.AD008K13805B7069a