users@jersey.java.net

Re: entity providers for collections?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 19 Aug 2008 09:23:55 +0200

Hi Lars,

Your link to Guice's TypeLiteral did the trick. We asked for and
obtained permission from the authors to copy the code and the result
is the GenericEntity class that is part of the 0.9 JAX-RS API.

So if our paths ever cross i owe you a some beers, or whatever is
your imbibing preference.

Thanks!
Paul.

On Apr 2, 2008, at 1:07 PM, Lars Tackmann wrote:

> On Wed, Apr 2, 2008 at 12:08 PM, Paul Sandoz <Paul.Sandoz_at_sun.com>
> wrote:
>> FSauer_at_dsthealthsolutions.com wrote:
>>
>>>
>>>
>>> How does one write JAXB entity providers for collections?
>>> Wrapping them in
>> a class works fine, but
>>> I want to be able to return List<SomeType> from resource methods
>>> but I
>> can't figure out how to register the providers.
>>> type-erasure makes this hard..... if not impossible. How do you
>> distinguish multiple providers for ArrayList if the element type
>>> is not available at runtime??? Any help is appreciated,
>>>
>>>
>>
>> Currently we cannot support it.
>>
>> The isWriteable method could have the instance as a parameter,
>> then one can
>> do some checking on the classes of the entries in the collection,
>> but that
>> is not very efficient. As you say because of type erasure we are
>> in a very
>> tricky situation.
>>
>> Marc and I tried to make Response and Response.ResponseBuilder
>> generic but
>> gave up because we could not find a way to correctly define the
>> generic
>> types and work in a type safe manner. If anyone can find such a
>> solution i
>> will buy them many beers!
>
> I am not sure I completly graps the problem since I have not yet
> started looking at the Jersey code, but with regards to runtime
> type erasure check TypeLiteral<T> from Google Guice:
>
> http://google-guice.googlecode.com/svn/trunk/src/com/google/inject/
> TypeLiteral.java
>
> it is pretty nifty solution to retrieve types at runtime. With regards
> to hacking on the Jersey code, do you have a janitor style TODO lists
> (like http://janitor.kernelnewbies.org/) with tasks that are
> comprehensable for a Jersey source code newbie ?
>
>
> --
> Yours sincerely
>
> Lars Tackmann
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>