On 10/21/07, Don Brown <[EMAIL PROTECTED]> wrote: > > The more I study Rest [1] and now having used it in a production > application, the more I'm convinced Struts 2 needs to be the premier > way to write Restful web applications. The HTTP-based Rest theory is > well-suited to the action-based Model 2 design as makes it easy to > write naturally Restful applications. While there are several Java > web service frameworks that support Rest (notably Apache CXF), there > are few Java web frameworks that help you write human and > machine-facing web applications using Rest principles. > > What is missing in Struts 2 is that extra bit a framework can do to > take away the broilerplate code and let you focus on your application. > Therefore, I'd like to propose we add the Rest Plugin, now residing > in the Struts sandbox, to the list of bundled Struts 2 plugins. With > the plugin, I've taken what I've learned having put a Restful Struts > 2-based application into production and tried to get the plugin to do > all the tedious, repetitive work, all the while following the > established patterns implemented by Ruby on Rails. > > I've written a quick guide to using the plugin in our plugin registry > [2] and have included a showcase web application with the plugin code > [3]. > > BTW, I'll be speaking at ApacheCon about writing Rest applications > using Struts 2, and it is preparing for that talk that prompted this > plugin. I looked at the last Rest application I wrote using Struts 2 > and decided that as a framework, Struts could do better. > > Don > > [1] > http://www.amazon.com/RESTful-Web-Services-Leonard-Richardson/dp/0596529260 > [2] http://cwiki.apache.org/S2PLUGINS/rest-plugin.html > [3] > http://svn.apache.org/repos/asf/struts/sandbox/trunk/struts2-rest-plugin//showcase/
Nice work Don! One thing I think we should change is /orders/{id};edit to /orders/{id}/edit - much like Rails 2.0 supports. >From http://weblog.rubyonrails.com/2007/9/30/rails-2-0-0-preview-release: *Action Pack: Resources* This is where the bulk of the action for 2.0 has gone. We've got a slew of improvements to the RESTful lifestyle. First, we've dropped the semicolon for custom methods instead of the regular slash. So /people/1;edit is now /people/1/edit. Also, is "Resource" required as the suffix for classes? I think this is something that might turn off users because they're so used to using "Action". Can we make this customizable? If so, maybe we should allow "Controller" as well (if you want to attract folks familiar with Rails). How does the rest-plugin work for Actions/Resources in sub-packages? Does it add an extra directory name in the URL? Lastly, I really like where you're going with this support in Struts, primarily because I believe there's a lot of good points in the "Life Above the Service Tier"[1] article posted to TSS recently. It'd be very interesting to develop a sample application that uses SOFEA principles - possibly using the rest-plugin and YUI. If SOFEA is a productive way to develop web applications for SOA backends, Struts (and other request-based frameworks like Stripes and Spring MVC) could be ahead of the game because they aren't as tightly coupled to rendering server-side pages as the component-based frameworks like JSF, Tapestry and Wicket. In reality, I doubt SOFEA will eliminate the usage of popular server-side page rendering frameworks like PHP, RoR, ASP.NET and all the Java ones. However, it would be nice to have a framework that supports both server-side and client-side pages and treats SOFEA architectures as first-class citizens. After all, what if the "component" is the widget framework (YUI, Dojo, Ext JS)? I believe components at the UI layer (instead of in the web framework) is a very compelling idea for companies that support "polygot programming". [2] Matt [1] http://www.theserverside.com/news/thread.tss?thread_id=47213 [2] http://memeagora.blogspot.com/2006/12/polyglot-programming.html