users@jersey.java.net

Re: entity providers for collections?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 02 Apr 2008 14:42:34 +0200

Lars Tackmann wrote:
>> 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,

It is not so much with Jersey code (just yet) more so with the JAX-RS
Response and Response.ResponseBuilder. But I do have a task to ensure
that the type information (and annotations) are extracted from the
method signature and passed to the message body reader. So it will be
possible to support Collection<Bean> for reading reasonably soon.


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

Very interesting! Then one could do:

  Collection<Bean> c = ...
  Response.ok().entity(c, new TypeLiteral<Collection<Bean>>() {});

I reckon that is the best we could do.


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

Unfortunately not :-( in a bit of a catch 22 at the moment furiously
coding to meet deadlines, so code base is changing and I don't currently
have the time to create and maintain such things.

The two best things we have are the unresolved issues [1] and this email
list :-)

For example, two related issues that may be relatively easy/isolated to fix:

   https://jersey.dev.java.net/issues/show_bug.cgi?id=29
   https://jersey.dev.java.net/issues/show_bug.cgi?id=50

An interesting feature request is this:

   https://jersey.dev.java.net/issues/show_bug.cgi?id=39

which is reasonably isolated.

I can provide further information on the above as requested :-)

Paul.

[1]
https://jersey.dev.java.net/issues/buglist.cgi?Submit+query=Submit+query&component=jersey&issue_status=NEW&issue_status=STARTED&issue_status=REOPENED&version=current&email1=&emailtype1=exact&emailassigned_to1=1&email2=&emailtype2=exact&emailreporter2=1&issueidtype=include&issue_id=&changedin=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&short_desc=&short_desc_type=fulltext&long_desc=&long_desc_type=fulltext&issue_file_loc=&issue_file_loc_type=fulltext&status_whiteboard=&status_whiteboard_type=fulltext&field0-0-0=noop&type0-0-0=noop&value0-0-0=&cmdtype=doit&order=Reuse+same+sort+as+last+time

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109