Earthly Powers
- All
- Fast Infoset
- General
- Java
- REST
On Web resource mapping with JAX-RS
Bill de hÓra has a great blog entry on web resource mapping criteria for evaluating Web frameworks.
In the current JAX-RS API it is easy to do "function passing" or "surrogate". So following Bill's example...
The following is a resource using the "function passing" approach:
@UriTemplate("document/xyz")
public class FunctionPassingResource {
@HttpMethod
public InputStream getDocumentOrEditForm(@QueryParam("f") String f) {
if (f.equals("edit)) {
// return edit form representation
...
} else {
// return document representation
...
}
}
} The following is a resource using the "surrogate" approach:
@UriTemplate("document/xyz")
public class FunctionPassingResource {
@HttpMethod
public InputStream getDocument() {
// return document representation
}
@UriTemplate("edit")
@HttpMethod
public InputStream getEditForm() {
// return edit form representation
}
}IMHO JAX-RS is more suited to the "surrogate" approach. This approach is also used in the Atom server example of Jersey to distinguish between read only and read/write URIs of Atom entries. See the break down of the URIs here.
Posted at 09:15PM Aug 14, 2007 by Paul Sandoz in REST | Comments[0]