jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: Hypermedia - Take 2

From: Markus KARG <markus_at_headcrashing.eu>
Date: Thu, 4 Aug 2011 20:18:26 +0200

I do not know other clients as I live completely in the Java universe for
the past decade(s), but I assume that they must be able to deal with
relative links, since relative links are an existing entity in the www. So
if those would not be able to manage them, how should they browse the
relative part of the web?

> -----Original Message-----
> From: Bill Burke [mailto:bburke_at_redhat.com]
> Sent: Donnerstag, 4. August 2011 01:08
> To: jsr339-experts_at_jax-rs-spec.java.net
> Subject: [jsr339-experts] Re: Hypermedia - Take 2
>
> ARe there really any sophisticated REST client APIs for other
> languages?
> I guess what i'm saying is that Sergey has a point. While we can
> build in some nice client-side support for relative links, other
> languages might not have that capability and it would be easier for
> them
> to code against absolute links. What does it look look in Javascript?
> Can you take advantage of relative links easily there?
>
> On 8/3/11 4:12 PM, Sergey Beryozkin wrote:
> > Hold on :-) Please don't try to prove me that in the example you
> listed relative URIs are better, it's obvious, isn't it ?
> > I can easily come up with the example which will show that for many
> realistic payloads the actual links will consume a very small
> percentage,
> > just don't have time for a ping-ball game really.
> > Can you type a bit the client code which consumes those links ? I
> nearly bet you won't match the simplicity of code dealing with absolute
> URIs.
> > Of course, UriBuilder can help on the client side, but simpler
> clients will also have to do those ugly checks like 'if ends with / and
> starts with / then do this otherwise that'
> >
> > Sergey
> > ________________________________________
> > From: Markus KARG [markus_at_headcrashing.eu]
> > Sent: 03 August 2011 18:09
> > To: jsr339-experts_at_jax-rs-spec.java.net
> > Subject: [jsr339-experts] Re: Hypermedia - Take 2
> >
> >>> +1. Absolute as a default is obviously more interoperable (or
> >> portable, to use your terminology).
> >>>
> >>>> S.B - I actually did not mean 'portable', it just got typed out
> >> somehow and then I realized I actually meant 'interoperable' :-)
> >>
> >> FWIW, on a second thought, Jan may have a valid point here -
> relative
> >> links may be significantly more efficient esp.
> >> when used as part of small message payloads. Having "workaround" the
> >> option for ill-behaved clients may be good enough
> >> and we may not need to trade the default efficiency for interop in
> this
> >> case.
> >>
> >> S.B. That's OK.
> >> Personally, the idea of writing the client code which checks the
> links
> >> and then goes and builds absolute URIs as opposed to doing immediate
> >> GET
> >> makes me a bit nervous, especially that I will probably write not a
> >> very good server code which will 'cost' WEB extra
> "http://myhost.com"
> >> per link :-)
> >> But of course it's up to a concrete application code which does
> decide
> >> to use @Ref on which form the links should take, so I'm going to
> >> support
> >> whatever decision the group takes
> >
> > Imagine your payload is a shopping cart that contains 10 articles.
> Each
> > article is described just by a URI pointing to the full description.
> >
> > <Cart>
> > <Item
> >
> href="http://api.genericshopshoftware.info/shops/supercheapelectronics/
> shopp
> > ingcart/items/0" />
> > <Item
> >
> href="http://api.genericshopshoftware.info/shops/supercheapelectronics/
> shopp
> > ingcart/items/1" />
> > <Item
> >
> href="http://api.genericshopshoftware.info/shops/supercheapelectronics/
> shopp
> > ingcart/items/2" />
> > <Item
> >
> href="http://api.genericshopshoftware.info/shops/supercheapelectronics/
> shopp
> > ingcart/items/3" />
> > <Item
> >
> href="http://api.genericshopshoftware.info/shops/supercheapelectronics/
> shopp
> > ingcart/items/4" />
> > <Item
> >
> href="http://api.genericshopshoftware.info/shops/supercheapelectronics/
> shopp
> > ingcart/items/5" />
> > <Item
> >
> href="http://api.genericshopshoftware.info/shops/supercheapelectronics/
> shopp
> > ingcart/items/6" />
> > <Item
> >
> href="http://api.genericshopshoftware.info/shops/supercheapelectronics/
> shopp
> > ingcart/items/7" />
> > <Item
> >
> href="http://api.genericshopshoftware.info/shops/supercheapelectronics/
> shopp
> > ingcart/items/8" />
> > <Item
> >
> href="http://api.genericshopshoftware.info/shops/supercheapelectronics/
> shopp
> > ingcart/items/9" />
> > </Cart>
> >
> > Now we do the same relative.
> >
> > <Cart>
> > <Item href="0" />
> > <Item href="1" />
> > <Item href="2" />
> > <Item href="3" />
> > <Item href="4" />
> > <Item href="5" />
> > <Item href="6" />
> > <Item href="7" />
> > <Item href="8" />
> > <Item href="9" />
> > </Cart>
> >
> > I think this spares rather lot of bandwith (just calculate the
> percentage if
> > you like -- visually it looks like saving 75%), so few more
> complexity in
> > the code pays off very soon (I don't know about your's, but my
> bandwidth is
> > rather expensive).
> >
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com