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