dev@jsr311.java.net

Re: Representation<T> and Entity<T>

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Tue, 10 Apr 2007 09:09:06 -0400

On Apr 10, 2007, at 5:56 AM, Jerome Louvel wrote:
>
>>> @Method
>>> public Entry postEntry(@Input InputStream data, @MediaType
>> String type) {
>>>
>>
>> How would one return the media type, language, or content location?
>
> If the Entity class can be modified:
>
> public class Entity {
> @MediaType
> public String getType() {...}
>
> @RedirectRef
> public URI getContentLocation() {...}
> }
>
> Otherwise:
>
> @Method
> public @Metadata(mediaType="text/foo", language="en") Entry
> postEntry(@Input InputStream data, @MediaType String type) {
>
> or
>
> @Method
> public @MediaType("text/foo") @Language("en") Entry
> postEntry(@Input InputStream data, @MediaType String type) {
>
None of those helps when the return type can't be modified and the
media type isn't know in advance.

I like the idea of being able to specify additional metadata like
language declaratively but you do run into a problem with annotation
syntax: as soon as you have more than one field in an annotation you
are forced to include the field names even when only specifying the
value of one field where all the others have defaults. E.g. with one
field you can write:

@MediaType("text/foo")

with two you can write:

@MediaType(mediaType="text/foo", language="en")
or
@MediaType(mediaType="text/foo")

but you can no longer write @MediaType("text/foo").

You can always add more single field annotations but then you get an
explosion of annotation classes.

Marc.

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