dev@jsr311.java.net

Re: Representation<T> and Entity<T>

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 10 Apr 2007 17:22:55 +0200

Jerome Louvel wrote:
> Paul,
>
>> Because a developer has to create their own annotated class for such
>> common cases, like you did, rather than *reuse* Representation<T>.
>
> As I corrected in a later reply, I meant Entry instead of Entity.

I saw it :-) my response was based on that correction.


<snip>
> Maybe we should test those ideas on some concrete examples to see how well
> they float? I'm willing to write a Restlet-based prototype illustrating the
> pure annotation approach if that can help moving the debate forward.
>

OK, that would help. FWIW Marc and I have implemented quite a few
concrete, working and tested examples using Representation<T> and Entity<T>.

Perhaps we could take, as the first example, the image conversion
example that i referred to in another email?

Here is what it such an example may look like (minus the implementation)
using the API proposal:

import javax.ws.rs.ConsumeMime;
import javax.ws.rs.Entity;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.ProduceMime;
import javax.ws.rs.UriTemplate;
import javax.ws.rs.representation.Representation;
import java.io.InputStream;

@UriTemplate("imcon")
@ConsumeMime("image/*, application/octet-stream")
@ProduceMime("image/*")
public class ImConReosurce {

     @HttpMethod
     Representation<InputStream> postToConvert(
         Entity<InputStream> image) {
         ...
     }

     @UriTemplate("lastConverted")
     @HttpMethod
     Representation<InputStream> getLastConverted() {
         ...
     }

     @UriTemplate("numberConverted")
     @HttpMethod
     @ProduceMime("text/plain")
     String getNumberConverted() {
         ...
     }
}

(with a change of javax.ws.rs package and returning null this class
compiles according to the API and impl that will ship with R2 of SWDP)

Paul.

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