dev@jsr311.java.net

Issues 14, 15 refactoring _at_HttpMethod

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Fri, 12 Oct 2007 12:30:45 -0400

Issues 14[1] and 15[2] are about changes to @HttpMethod. Essentially
instead of:

@HttpMethod
@UriTemplate("foo")
public Foo getFoo()

you could write

@GET("foo")
public Foo getFoo()

I like the conciseness of this but @UriTemplate has other attributes
in addition to the template string and I don't think it makes sense
to duplicate these on other annotations. Instead I'd propose to make
@HttpMethod a meta-annotation and define a set of annotations for the
common HTTP methods using this meta-annotation, e.g.:

@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@HttpMethod("GET")
public @interface GET {}

Anyone could define their own annotations for additional HTTP methods
if they so desired since implementations would only look at the value
of meta-annotation to find the HTTP method for a given annotation.

With this you could write:

@GET @UriTemplate("foo")
public Foo getFoo()

It would be nice of we could also rename UriTemplate to something
shorter but URI is already taken...

Thoughts ?
Marc.

[1] https://jsr311.dev.java.net/issues/show_bug.cgi?id=14
[2] https://jsr311.dev.java.net/issues/show_bug.cgi?id=15

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