Re: Representation<T> and Entity<T>

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Tue, 10 Apr 2007 08:54:41 -0400

On Apr 10, 2007, at 6:07 AM, Jerome Louvel wrote:
> To precise my previous response: I do see the value for a MediaType
> class
> and would prefer to see it added at the JDK level. But, I'm not
> against
> having it at the JSR level if it isn't possible to modify the core
> If all that you need is the media type as a String, then it seems
> as easy to
> do:
> public Entry postEntry(@Input InputStream data, @MediaType String
> type)
> than
> public Entry postEntry(@Input InputStream data, MediaType type)
If we relax the requirement on Entity<T> for a method parameter, you
could just do:

public Entry postEntry(InputStream data, @HeaderParam("Content-Type")
String type)

What is the value of the @Input annotation ?

> This is mostly a matter of taste. IMO, the annotation does make it
> a little
> more obvious that the value of the "type" parameter will be
> injected using
> the request's entity media type, rather than magically bound to the
> first
> parameter instance of the MediaType class.
I agree, I think we should allow at most one "bare" (not annotated)
method parameter that is bound to the request entity body.


Marc Hadley <marc.hadley at>
CTO Office, Sun Microsystems.