users@jsr311.java.net

Re: _at_PathParam(...) PathSegment ps

From: Stephan Koops <Stephan.Koops_at_web.de>
Date: Wed, 21 May 2008 10:20:34 +0200

Hi,
>>> *_at_PathParam(...) PathSegment*
>>> while thinking how to implement @PathParam for a PathSegment: an uri
>>> template variable could be represent a part of a path segment (e.g.
>>> @Path("ab{CD}ef{GH}") ), but also multiple path segments: (e.g.
>>> @Path(value="ab{CDEF}gh", limited=false) ).
>>> For the first case it seems useful to me to return for
>>>> @PathParam("CD") PathSegment ps
>>> and for
>>>> @PathParam("GH") PathSegment ps
>>> the same (or two equal) objects implementing PathSegment.
>>> But what happens, if CDEF in @Path(value="ab{CDEF}gh",
>>> limited=false) matches "12/34" or "12/34/56"? What is the value of
>> IMO, limited=false has no affect for @Path(value="ab{CDEF}gh",
>> limited=false.
> Right, the template var has to be at the end of the URI for
> limited=false to have any effect.
Ok, then we have
> @Path(value="ab{CDEF}", limited=false)
and
> @PathParam("{CDEF}") PathSegment ps
with "ab12/34/56" to match. What it the path in the PathSegment? "12"?
"56"? "12/34/56"? The first and second is IMO not useful and the last is
not realy one path segment.
>>> If I use
>>>> @Path(value="{VAR}", limited=false)
>>> and VAR matches "jkl/mno/pqr", than this are three path segments,
>>> e.g. from UriInfo.getPathSegments(), in my understanding. I think it
>>> will causes misunderstanding, if we define "jkl/mno/pqr" as one path
>>> segment, if it is matched by one variable.
>> In this case, why not require it to match a List or Array?
>>
>> @Path(value="{VAR}", limited = false)
>> @GET
>> public String get(@PathParam("VAR") List<PathSegment> var)
>> {
>> }
> Interesting idea but it does raise some tricky questions, e.g.:
>
> @PathParam("VAR") List<String> var - would you get a single string
> with the whole path or a list with an entry per path segment.
>
> Currently @PathParam doesn't allow List, Set or SortedSet like
> @HeaderParam, @QueryParam and @MatrixParam.
After I've end my email I also thought about Bills proposal. But Marcs
objection is also good.

Marc, 6 weeks ago we discussed if @Path("{p}/abc/{p}") should be allowed
or not. (my request:
https://jsr311.dev.java.net/servlets/ReadMsg?list=users&msgNo=187,
section "Annotations in root resource classes"; your answer:
https://jsr311.dev.java.net/servlets/ReadMsg?list=users&msgNo=191).
You said that it is allowed, but also agreed with me, that it is odd.
You argued, that a developer could read it by
UriInfo.getPathParameters(), which returns a MultivaluedMap. Why are
List, Set and Sorted Set not allowed for @PathParam (Perhaps only List) ?
> No, only resource classes and methods can use @*Param. Providers have
> a singleton lifecycle and fixed method signatures...
Oh, you are right. I mixed it with @Context annotated fields / bean
setters.