users@jersey.java.net

Re: entity providers for collections?

From: Lars Tackmann <lars_at_randompage.org>
Date: Wed, 2 Apr 2008 13:07:08 +0200

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