users@jax-rs-spec.java.net

[jax-rs-spec users] [jsr339-experts] Re: Re: ParamConverter and Collections

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Thu, 14 Aug 2014 15:26:55 +0100

Hi Santiago,
On 14/08/14 14:54, Santiago Pericas-Geertsen wrote:
>
> On Aug 14, 2014, at 9:51 AM, Santiago Pericas-Geertsen <Santiago.PericasGeertsen_at_oracle.com> wrote:
>
>> Sergey,
>>
>> Maybe there's a clarification needed here. But, let's assume that you do search/implemente a List<MyAClass> converter, what would be the format of the string that this converter will accept/produce?
>
> Sorry, just realized that you are asking the same question :)
>
Np, indeed, using ParamConverters to convert a String to a typed
Collection does not seem to work well.
Thanks, Sergey
> -- Santiago
>
>> On Aug 13, 2014, at 5:11 PM, Sergey Beryozkin <sberyozkin_at_talend.com> wrote:
>>
>>> Hi Marek
>>>
>>> Can you please be very nice tomorrow :-) and reply to the following:
>>>
>>> A CXF user is wondering if CXF is compliant or not with respect to the way it treats collections and ParamConverters.
>>>
>>> Consider:
>>>
>>> @GET
>>> public Response get(@QueryParam("a") MyAClass a);
>>>
>>> ParamConverterProvider.getConverter(MyAClass.class, MyAClass.class, annotations);
>>>
>>> would return the converter.
>>>
>>> Now, next we have
>>>
>>> @GET
>>> public Response get(@QueryParam("a") List<MyAClass> a);
>>>
>>> The user expects that ParamConverterProvider is asked to return a converter for List<MyAClass>.
>>>
>>> I said no, there was an agreement that the runtime was dealing with managing the actual Lists or Sets, and ParamConverterProvider would only be asked to provide a converter for MyAClass.
>>>
>>> My other argument was that if the runtime were to ask to provide the list/set converters then, given a query like "?a=2&a=4", the runtime would have to pass the actual "a=2&a=4" String to the converter (possibly re-created by the runtime in case the original query is more involved, with multiple 'a' being mixed with other parameters) for it to parse it in order to convert to List/Set. This appears to be fundamentally wrong to me: this would mean that the same converter would also have to be prepared to parse "a=2;a=4" to support Matrix parameter lists. No idea how would one get the converters to convert a list of headers to List/Set, what the runtime would pass to converter.fromString() in case of multiple headers ?
>>>
>>> To summarize, I think it is the job of the runtime to take care of managing the actual lists/sets holding multiple parameters.
>>>
>>> Does it Jersey do it differently ? Bill, what about RestEasy ?
>>>
>>> Thanks, Sergey
>>
>