RESTFaces
Ryan J. McDonough has written a post called "Not much is RESTful in RestFaces and JBoss Seam", which discusses the RESTfaces JSF extension. On RESTfaces he concludes:
"I just came across a quick article on The Server Side about a JSF framework called RESTFaces. My initial reaction was 'oh cool, a JSF framework that might adhere to RESTful principals.' Sadly, there isn’t very much that is “RESTful” about RESTFaces."
Unfortunately, I have to agree. REST is becoming something of a buzzword these days and I suspect RESTfaces might be suffering from that instead of focusing on what it actually does, which is provided a patch for JSF to allow CGI style links. Looking at the documentation, it says:
" RESTfaces for JavaServer™ Faces Technology make it possible to write bookmarkable pages using JavaServer™ Faces."
And that's true, it does, You'd think JSF would just get fixed to align itself with web architecture fundamentals, but ok. The documentation describes how links are provided,
"We want to jump to a page containing item details, when the user clicks on the item link. The resulting detail page should be bookmarkable. The best way to accomplish this is using HTTP parameters."
Parameters are not the best way to do this in general, though they might well be wrt JSF. The documentation goes on to say:
" Now let's see how it's possible to invoke the action with RestFaces."
The giveaway word is "action"; unfortunately that's not REST style, that's RPC. Here's how action is marked up:
<rest:link value="item">
<f:param name="itemId" value="#{item.id}" />
<h:outputText value="#{item.name}" />
</rest:link>
which strikes me as quite cluttered; an "a" tag with href seems like a nicer option.
Looking through the rest of the documentation suggests that RESTfaces is dealing with incidental complexity introduced by JSF itself, as the majority of the examples are about managing internal wiring and mappings. RESTfaces as far as I can tell is an RPC technology. I've described the technique it's using to provide links as "CGI/RPC explicit" in the past. This is where you pass the id of the resource you care about as a query parameter to a script, instead of addressing the resource directly. In OO terms that's just like hiding all your domain objects behind manager classes and passing primary keys around - something that would be unacceptable for modern Java development.
I suspect RESTfaces does what it can to patch around JSF's limitations to provide bookmarks, but part of me wonders, why bother? JSF is clearly not focused on or suitable for working in the REST style to the extent REST principles seem to be actively excluded from the design. So, in the context of the way JSF does things, it's fine to add CGI style extensions for something as fundamental as linking, but then the REST moniker isn't appropriate. I understand I'm being hard on RESTfaces here; in fairness frameworks not being aligned with the Web is the norm and I'm reminded about what Mark Nottingham said about web frameworks:
"URIs are the lynchpin of the Web; to get the full value of the Web infrastructure, you need to be able to identify every interesting part of your Web application with a URI. Unfortunately, common Web APIs don’t encourage this, or even actively discourage it."
Struts2 REST
On a more positive note, Stefan Tilkov links to some material about REST support in Struts2; it looks like someone did some digging into the Web's design. Check it out.
SpringMVC + Restlet
Personally, I think unifying SpringMVC, RESTlet routers and JSR311 annotations would give you most of what you need.
If you've used Django or Rails, then SpringMVC has a controller/view request model that will be intuitive, while being familiar enough to the legions that grew up on Struts ActionController. According to Jurgen Hoeller's post, "Annotated Web MVC controllers in Spring 2.5", Spring 2.5 introduces some web annotations:
"So how does Spring 2.5's annotation-based controller approach fit into this picture? Quite simple: It is essentially an alternative controller type supported by the DispatcherServlet / DispatcherPortlet, not implementing a specific interface but rather using annotations to express request mappings for specific handler methods. It is primarily a next-generation style for implementing multi-action controllers, superseding Spring's good old MultiActionController class"
I think once you go down the road of using annotations such as @Controller and @RequestMapping for HTTP, you'll end up looking at JSR311 annotations.
Beyond JSR311, the best URI mapping I've seen in the Java space is RESTlet's Router API. Here's an example:
Router router = new Router(getContext());
router.attach("/users/{user}", UserResource.class);
router.attach("/users/{user}/orders", OrdersResource.class);
router.attach("/users/{user}/orders/{order}", OrderResource.class);
which is quite a bit more flexible than the default mappers shipped with SpringMVC. As an aside Guice Binders vaguely remind me of Restlet Routers. I'm guess I'm saying that your Java interfaces are merely Resource implementations ;)
19 Comments
I wouldn't be too hard on 'id' query string parameters. Yeah, they aren't as tidy looking, but they are still just as much part of the URL as path components are. The URL format doesn't really have much architectural significance.
"...which strikes me as quite cluttered; an "a" tag with href seems like a nicer option."
Are you advocating only coding in the expected content-type? Granted, having the natural representation for HTML is much easier to read and maintain, but that assumes text/html and no other. Also, applications can be very complex and having a one to one binding between development artifact and content-type may not be practical.
I agree with David. The syntax of an HTTP URL is just a clue about whether REST or RPC or some other architecture is being used. I experienced this when implementing an Atom Publishing Protocol server. My server uses "edit" and "edit-media" links of the form {collection-uri}?entry={atom:id} and {collection-uri}?media={atom:id}. It looks a lot like "CGI/RPC Explicit" but it is just as RESTful as any other AtomPub server that doesn't require that the atom:id of an entry be the same as its edit URI.
In particular, using links of the form {collection-uri}/entry/{atom:id} and {collection-uri}/media/{atom:id} would not change how my applications work at all, except making the web servers URL mapping configuration more complicated.
"The syntax of an HTTP URL is just a clue about whether REST or RPC or some other architecture is being used. "
Links of the form "{collection-uri}?entry={atom:id}" identify the collection resource, not the entry. The question mark in the URI is used to separate the URI from parameters which are appended to it to perform an operation. I understand this might not be a well known aspect of HTTP/URIs.
Bill, I consider you to be an authority on such matters, but I cannot find anything in RFC 3896 or RFC 2616 that supports that line of thinking. What am I overlooking?
RFC 3986 says "The query component contains non-hierarchical data that, along with data in the path component (Section 3.3), serves to identify a resource[.]" Basically, there is basically no distinction between "/" and "?" other than syntax and that segments between slashes have some hierarchical properties that query strings don't have. RFC 2616 gives no semantics to query strings whatsoever.
I am particularly interested in hearing of any advantages that your interpretation of query string semantics over mine.
Thanks,
Brian
I don't have time to dig up the reference now, but I believe Roy said on rest-discuss that the special handling of "?" URIs is a legacy and no longer relevant in practice.
The thread you are talking about is here: http://tech.groups.yahoo.com/group/re...
In that discussion, Bill brings up the point that RFC 2616, section 3.2.2 says "...the Request-URI for the resource is abs_path...." (omitting the query parameter).
There is a proposal for RFC2616bis to change this to include the query parameter:
http://www.w3.org/Protocols/HTTP/1.1/...
http://lists.w3.org/Archives/Public/i...
"There is a proposal for RFC2616bis to change this"
Yeah, they need to do that.
Wu9F1V sd89f984q34slf
100222SLSZL
In april 1871, bose in-ear headphones,melanie plans a surprise birthday party for ashley. scarlett goes to the mill after melanie asks her to stall him. bose on-ear headphones she and ashley chat about old times at twelve oaks. pioneer on headphone special he hugs her in an attempt to console her, pioneer on headphones because she is overwhelmed by the memories and hates to look back at the past.. http://www.salebose.com/
Thank you! I would now go on here every day!
http://www.infls.com
We are supply all kinds brand goods:
Shoes: Jordan, Nike,http://www.tougg.com Prada, Puma, LV, Timberland, Pual Smith, D&G, Supra, Adidas, Yeezy, ATO, CR etc.
Clothing: Coat, Jacket, T-shirt, Suit, Sweater, Jeans, Bikini, Jersey etc.
Handbags: Coach, Berberry, Balenciaga, http://www.bayugg.comJuicy, LV, ED-Hardy, MIUMIU, Chanel, Chole etc.
Accessories: Belts, Sunglasses, Hats, Necktie,http://www.tougg.com Scarf, Jewelry etc.
As the commodities we supply are of excellent quality http://www.aheadtrade.com and low price,
we have won a very good reputation from our clients all over the world.
If you are interested in any of our products, please don't hesitate to contact with me by email.
I trust that through our cooperation we shall be able to conclude some transactions with you in the near future.
Website: http://www.mbtshoe.co.uk
http://www.aheadtrade.com
http://www.bayugg.com
http://www.tougg.com
Best regards!
100309SLZZQSet some royalty your light night set, all day, for example, you can run this birkin Louis Vuitton handbags , no matter how boring your attachments may seem, this package is guaranteed to you to set really amazing and complex Cheap Gucci Handbags saw a day.This package does not in fact is lame, however, it is some lame, clarify this in addition to other casually elegant fabric bag. It has been all throughout the mosaic keeps this wallet gives off impressive glitzy effect of an appeal. This too can be drag-and-diploma by locking firmware GHD Hair Straighteners gold tone series in front of the open and will display a small pocket replacing it with the logo exposed skin. As a fully what Chloe Designer Chanel Handbags see more these days, it also comes with a gold tone chain shoulder strap.Because this Hair Straighteners - Lame shoulder bag seem sumptuousdining has been estimated to apply the General. But the luxuriousness of course you can to do this discount louis vuitton handbags . http://www.uggbootssaleonline.com/
100309SLLQY
Woman will begin with bailey button uggs certainties, she shall end in ugg classic cardy sale doubts,but if he will be content to begin with louis vuitton handbags sale doubts, he shall end in certainties. Determined to act prada handbags 2009 Decisivly and to bear the consequences.In this cheap coach handbags world, hesitation can not access to success. Laziness as a lock,which bolts you out of the storehouse of mui mui handbags information and makes you an intellectual starveling.Early to guess handbags sale bed and early to rise jimmy choo handbags makes a man healthy,wealthy,and wise. http://www.hideboots.com/products_new...
<p><a href="http://www.ghdssite.com/"><strong>cheap GHD hair straighteners</strong></a></p>
<p><a href="http://www.ghdssite.com/"><strong>GHD straighteners wholesale</strong></a></p>
<p><a href="http://www.ghdssite.com/"><strong>GHD styler</strong></a></p>
<p><a href="http://www.ghdssite.com/"><strong>GHD IV styler</strong></a></p>
<p><a href="http://www.ghdssite.com/ghd-babyliss-hair-straighteners-p-17.html"><strong>GHD Babyliss Hair Straighteners </strong></a></p>
http://www.onlypuma.com puma shoes
http://www.onlypuma.com/mens-puma-sf-... Puma - SF Drift Cat
http://www.onlypuma.com/mens-puma-bay... Puma Baylee Future Cat II
http://www.onlypuma.com/mens-puma-dos... Puma Doshu Combat Shoes
http://www.onlypuma.com/mens-puma-flu... Men's Puma Fluxion II
http://www.onlypuma.com/mens-puma-fut... Puma Future Cat GT Ferrari
http://www.onlypuma.com/mens-puma-fut... Men's Puma Future Cat Lo Engine
http://www.onlypuma.com/mens-puma-fut... Puma Future Cat Low
http://www.onlypuma.com/mens-puma-laz... Puma Lazy Insect
http://www.onlypuma.com/mens-puma-sf-... Puma SF Trionfo Low
http://www.onlypuma.com/mens-puma-spe... Puma Speed Cat
http://www.onlypuma.com/mens-puma-spe... Puma Speed Cat Big
http://www.onlypuma.com/mens-puma-tri... Puma Trionfo Lo L II
http://www.onlypuma.com/mens-puma-tri... Puma Trionfo Low BAYLEE
http://www.onlypuma.com/mens-speed-ca... Speed Cat Big
http://www.onlypuma.com/puma-ducati-t... Puma Ducati Testastretta
http://www.onlypuma.com/puma-kimi-rai... Puma Kimi Raikkonen shoes
http://www.onlypuma.com/womens-puma-b... Puma Basket Brights
http://www.onlypuma.com/womens-puma-b... Puma Baylee Future Cat
http://www.onlypuma.com/womens-puma-d... Puma Drift Cat
http://www.onlypuma.com/womens-puma-e... Puma Engine Cat Low
http://www.onlypuma.com/womens-puma-e... PUMA Espera Patent FS
http://www.onlypuma.com/womens-puma-f... Puma Ferro Tessuto Shoes
http://www.onlypuma.com/womens-puma-f... Puma Future Cat Lo
http://www.onlypuma.com/womens-puma-f... Puma Future Cat Low
http://www.onlypuma.com/womens-puma-r... Puma Repli Cat
http://www.onlypuma.com/womens-puma-s... Puma SF Drift Cat
http://www.onlypuma.com/womens-puma-s... Puma Speed Cat Big
http://www.onlypuma.com/womens-puma-s... Puma Speed Cat Suede
http://www.nowghd.com/limited-edition... A woman seldom asks advice before she has bought her wedding clothes. I married beneath me. All women do. Any intelligent woman who reads the marriage contract, and then goes into it, deserves all the consequences. http://www.nowghd.com/ghd-babyliss-ha...
20100311SLLYP Transported with this idea, she could not forbear mbt chapa shoes acting with her head the thought that passed in her mind, when down came the can of mbt m walk shoes milk! And all her imaginary happiness vanished in a moment.A great mbt sport shoes poem is a fountain forever overflowing with the waters of wisdom and delight.Poet I mbt shoes sale who puts up a ladder to a star and climbs it while playing a violin.Humor has been well defined as thinking in mbt walking shoes while feeling in earnest.Words have a magical power. They can bring mbt womens m walk shoes either the greatest happiness or deepest despair; can transfer knowledge from teacher to students words enable the mbt lami sale orator to sway his audience and dictate its decisions. Words are capable of cheap mbt shoes arousing the strongest emotions and prompting all actions.The truth of her life was a desire to see sell mbt shoes beyond the surface for a glimpse of what it is that matters. http://www.mbtshoessaletoday.com/revi...
100312SLLQY
There is no royal road to science, and only those St Louis Rams jerseys who do not dread the fatiguing climb of gaining its numinous summits. To do whatever needs to be done to preserve this last and greatest bastion of freedom. We cannot always build Tennessee Titans jerseys the future for our youth, but we can build our youth for the future. If you would know the value of money, go and try to borrow some. To really understand a man we must judge him Los Angeles Lakers jerseys in misfortune. We have no more right to consume happiness without producing it than to consume wealth without Dallas Cowboys jerseys producing it.In delay there lies no plenty, Then come kiss me, sweet and twenty, Youth's a stuff that will not endure.Never leave that until tomorrow, which you can do today.Ordinary people merely think how Pittsburgh Penguins jerseys they shall spend their time; A man of talent tries to use it.. http://www.alihello.com/
http://www.onboots.com
http://www.onboots.com
http://www.onboots.com
http://www.onboots.com
http://www.onboots.com
http://www.onboots.com
http://www.onboots.com/kids-timberlan...
http://www.onboots.com/mens-timberlan...
http://www.onboots.com/mens-timberlan...
http://www.onboots.com/mens-timberlan...
http://www.onboots.com/mens-timberlan...
http://www.onboots.com/mens-timberlan...
http://www.onboots.com/mens-timberlan...
http://www.onboots.com/womens-timberl...
http://www.onboots.com/womens-timberl...
http://www.onboots.com/womens-timberl...
http://www.onboots.com/specials.html
--------------------------------------------------------------------------------------------------------------------------------
http://www.onlypuma.com
http://www.onlypuma.com/mens-puma-sf-...
http://www.onlypuma.com/mens-puma-bay...
http://www.onlypuma.com/mens-puma-dos...
http://www.onlypuma.com/mens-puma-flu...
http://www.onlypuma.com/mens-puma-fut...
http://www.onlypuma.com/mens-puma-fut...
http://www.onlypuma.com/mens-puma-fut...
http://www.onlypuma.com/mens-puma-laz...
http://www.onlypuma.com/mens-puma-sf-...
http://www.onlypuma.com/mens-puma-spe...
http://www.onlypuma.com/mens-puma-spe...
http://www.onlypuma.com/mens-puma-tri...
http://www.onlypuma.com/mens-puma-tri...
http://www.onlypuma.com/mens-speed-ca...
http://www.onlypuma.com/puma-ducati-t...
http://www.onlypuma.com/puma-kimi-rai...
http://www.onlypuma.com/womens-puma-b...
http://www.onlypuma.com/womens-puma-b...
http://www.onlypuma.com/womens-puma-d...
http://www.onlypuma.com/womens-puma-e...
http://www.onlypuma.com/womens-puma-e...
http://www.onlypuma.com/womens-puma-f...
http://www.onlypuma.com/womens-puma-f...
http://www.onlypuma.com/womens-puma-f...
http://www.onlypuma.com/womens-puma-r...
http://www.onlypuma.com/womens-puma-s...
http://www.onlypuma.com/womens-puma-s...
http://www.onlypuma.com/womens-puma-s...