users@jsr311.java.net

Re: Dealing with Matrix parameters

From: Sergey Beryozkin <sergey.beryozkin_at_progress.com>
Date: Mon, 24 Nov 2008 12:58:15 -0000

Hi,


>> 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.

ok - though it seems counterintuiitive to me. The docs for @Path state matrix parameters are not included - which to me says that
@Path value should not have them - but not that they have to be excluded in the resulting value. But I'm ok with fixing it anyway.


>> 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?

But how do you know then which path segment they're associated with ?
Consider 3 consecutive requests

/GET /a;p1=1/b;p1=1
/GET /a;p1=1/b

/GET /a/b;p1=1
So having MatrixParam("p1") checked on all the path segments won't give a user any indication at all what a requestor wanted to say

>> 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.

I honestly find it hard to understand. Where does the spec says that say
@Path("base/{tail}") needs to get replaced with something like

base(/.*)/([^ /]+?)(/.*)?

as opposed to

base/([^ /]+?)(/.*)?

Cheers, Sergey

_________________________________________________________________________
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


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jsr311.dev.java.net
For additional commands, e-mail: users-help_at_jsr311.dev.java.net