users@jsr311.java.net

Re: JSR311: WebAppExc subclasses? and: generic type for MessageBodyWriters

From: Bill Burke <bburke_at_redhat.com>
Date: Thu, 05 Jun 2008 17:16:06 -0400

Marc Hadley wrote:
> On Jun 5, 2008, at 4:50 PM, Bill Burke wrote:
>>
>> Why not templatize Response?
>>
>> @GET
>> Response<List<String>> get() {...}
>>
> Paul and I tried to do this a while back but, IIRC, we couldn't get it
> to work properly with ResponseBuilder. Definitely interested in a
> generic Response if we can get that to work.
>

Would be cool if you remembered why. In the case I'm proposing, you'd
get the type from the method signature anyways (which works).


>> I just had to do this exact thing so that RESTEasy's Client-side
>> framework could get type information from a response.
>>
>> An interesting thing about this approach is that you can do the same
>> hacks that Bob Lee's TypeLiteral. The code also looks a lot nicer and
>> less hacky then the TypeLiteral example you gave on the dev list.
>>
> I just checked in a new class GenericEntity:
>
> https://jsr311.dev.java.net/nonav/javadoc/index.html
>
> Its a bit different from the previous example I sent but its based on
> the same trick:
>
> List<String> list = new ArrayList();
> GenericEntity<List<String>> entity = new
> GenericEntity<List<String>>(list) {};
> Response response = Response.ok(entity);
>
> Marc.
> ---
> Marc Hadley <marc.hadley at sun.com>
> CTO Office, Sun Microsystems.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: users-help_at_jsr311.dev.java.net
>

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com