users@jsr311.java.net

Re: Dealing with Matrix parameters

From: Stephan Koops <Stephan.Koops_at_web.de>
Date: Mon, 24 Nov 2008 19:37:32 +0100

Hi Sergey,

> >> 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
You have to use @Context UriInfo and then get the last path segment of it.

> >> 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/([^ /]+?)(/.*)?
That I can't say. I also found nothing. But we talked about this on the mailing lists.
@Marc: Perhaps it is a bug in the specification.

best regards
  Stephan
_________________________________________________________________________
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