Re: General comments/questions/suggestions

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Fri, 18 Jan 2008 10:36:14 -0500

On Jan 17, 2008, at 6:08 PM, Bill Burke wrote:

> * Path, header and matrix params should be allowed to be convertable
> primitive types (int, float, etc...)
Agreed, this is already implemented in Jersey.

> * I asked for this before, but I'd like to be able to inject a
> PathSegment as a @PathParam:
> @GET @Path("{foo}/{bar}")
> public String get(@PathParam("foo") PathSegment foo,
> @PathParam("bar") PathSegment bar) {...}
Agreed, this would be useful for working with matrix parameters.

> * Question on MessageBodyWriter:
> The headers MultivaluedMap passed in is <String, Object> why the
> difference between MessageBodyReady which is <String, String>?
> * The header MultivaluedMap parameter passed into
> MessageBodyWriter.writeTo. Is this mutable? In other words, is the
> MessageBodyWriter allowed to add output headers? I think it should
> be allowed...
The map is mutable in a writer, i'll make an explicit mention of that
in the javadoc. Mutability is also the reason for <String, Object>: a
response builder can add objects like MediaType or NewCookie to the
list of outbound headers, we want to avoid a roundtrip to String if a
writer wants to further process those.

> * I asssume Response.ResponseBuilder.created() sends a Location
> header to the client?
Yes, I'll make that explicit in the javadoc.

> * Two methods to Response.ResponseBuilder should be added:
> temporaryHostRedirect(String path);

Yes, there are probably several others that would be useful.

> created(String path);
> This path should be concatenated to the base URI of the REST engine.
> For example, if JAX-RS is deployed from a WAR under
> Then:
> created("/customers/3424234"); should send a location:
> I believe redirects will be a common thing given it is a usage
> pattern in books like Restful Web Services. We need an easy way to
> create these URIs.
So essentially


would be a shortcut for


For the example you give above (assuming you have a Customer resource
with @Path("customers/{id}") you could also do something like


which perhaps we could shorten to:

created(Customer.class, "3424234")

> * How about replace @Path with @Uri "Uri" doesn't conflict with
> "URI".
I think path is more descriptive since the value is one or more path
segments rather than a complete URI. It used to be @UriTemplate but we
renamed it to @Path for this reason.

> * I'd like to add two types of wildcards to @Path mappings: '*' and
> '**'. The would basically work like Ant expressions. '*' would
> only consume one path segment, while '**' would consume multiple.
> @Path("**/*.jsp") maps to any path ending in ".jsp"
> @Path("*.jsp") only maps to one path segment of .jsp files.
> @Path("**/foo/**/bar") matches with "x/y/z/foo/1/2/bar"
> Also '**' could be used with a PathParam and PathSegment:
> @Path("customers/{id}**/address")
> @GET
> public String getAddress(@PathParam("id") PathSegment[] id) {...}
> The interesting side effect with having wildcard ability is that JAX-
> RS could totally replace Servlets.
Rather than make up something new, I'd rather follow the UriTemplate
syntax when that gets more stable:


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