MVCJ
Paul Sandoz about Jersey's (the JSR 311 reference implementation's) UI support:
Perhaps a little know fact (I should have blogged about it sooner) is that Jersey has support for the MVC paradigm and pluggable template processing.
Even though I haven't played with it yet, this seems very cool – although one could criticize that the right way would have been to improve the Servlet and JSP APIs, adding UI processing to the JAX-RS API layer is a second best solution I can live with.
I find I still can’t get over the fact that they’ve called the package “javax.ws.rest”, and the byline is “RESTful Web Services made easy in Java”. Do we really have to have the WS association…?
Well, you know it’s just Web services in the loosest definition of the term …
I saw this in the early releases of Jersey and wondered… WTF? It’s not like there aren’t already a couple of dozen MVC frameworks out there that do a pretty decent job of the presentation layer. Did they think they could crack this nut better than everyone else as a side effect of building out the JSR 311 reference implementation? My advice: focus on a decent RESTful interface/implementation for Java and don’t allow yourself to get sidetracked with distractions.
Gavin - they’ve not tried to force it into the standard, just added it as an option to the RI. I’m happy to be able to play with it …
I guess I should have elaborated on why I think this is a Bad Thing:
I actually think the MVC approach they have come up with is pretty cool as well (it seems very similar to the way Lift works in this regard), but my preference would be that it be clearly separated from anything to do with the JSR 311 reference implementation.
I’ve actually used this and implemented a small application that does have a UI.
To adress the concerns: the UI stuff is pretty much separated from the actual javax.ws.rest implementation. And it is designed such that existing templating/UI approaches are to be reused. That is, they don’t implement their own UI framework, but rather make it easy to plug in existing ones. The default implementation shipped simply allows to call out to JSPs, but you could probably easily integrate any of Spring, Velocity, etc.
What’s more annoying is that there is an impedance mismatch between browsers and non-browser clients (user agents). For example, in response to a POST you would usually want to return a 201 Created, with a Location header. But sadly, browsers don’t support this. There are some more problems like this, and I feel it’s not yet really thought out how to solve those issues.