Re: JSR311: URI-based conneg support

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Mon, 19 May 2008 10:25:17 -0400

On May 17, 2008, at 4:50 AM, Stephan Koops wrote:
> sounds good to me.
> To (iii): You mean rename UriInfo.getPathExtension() to something
> like getConnegExtensions() ?
Yes, something like that.


> Marc Hadley schrieb:
>> While building our demo for JavaOne we ran into some usability
>> issues with the current support for URI-based conneg. Currently the
>> URIs returned by UriInfo are the actual request URIs rather than
>> those used in matching after URI preprocessing (see section 3.7.1
>> of the spec). E.g.
>> GET /foo/bar.html with an ApplicationConfig that maps "html" =>
>> "text/html"
>> UriInfo.getRequestURIBuilder().path("baz").build() => "/foo/
>> bar.html/baz"
>> This isn't generally what you want. You can do:
>> UriInfo.getPlatonicRequestUriBuilder().path("baz").build() => "/foo/
>> bar/baz"
>> which is better, but you have to remeber to use the platonic
>> builder and often what you really want to get is "/foo/bar/
>> baz.html", so then you have to do
>> UriInfo
>> .getPlatonicRequestUriBuilder
>> ().path("baz").entension(UriInfo.getPathExtension()).build()
>> We think it would be better if you could just write:
>> UriInfo.getRequestURIBuilder().path("baz").build() => "/foo/bar/
>> baz.html"
>> To do this we propose the following changes:
>> (i) change the way that UriInfo works such that the URIs returned
>> are post-section.3.7.1-processing
>> (ii) remove the "platonic" URIs from UriInfo as all methods are now
>> platonic.
>> (iii) change the getPathExtension method so that it returns the
>> extension extracted by section.3.7.1 processing - we'd also rename
>> it in the process.
>> (iv) change the semantics of UriBuilder.extension so that it
>> specifies an extension that will be appended to the final path
>> segment during build().
>> (v) add a new UriBuilder method to get the current value of (iv)
>> (vi) Specify that the UriInfo methods that return a UriBuilder set
>> the extension property (iv) based on the current value of (iii).
>> With these changes the URIs you get from UriInfo correspond to
>> those used in matching requests to resources (as is already the
>> case for the rewritten Accept and Accept-Language headers).
>> Builders you get from URI info are preconfigured to use the same
>> URI-based conneg that the request used so its easy to build
>> representations with links to representations using the same media
>> type and language. Its also easy to build platonic URIs just by
>> unsetting the value of (iv) after you obtain the builder from
>> UriInfo.
>> Thoughts, comments ?
>> Marc
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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