Overall, you'll find WebWork 2 and Spring MVC more similar than not, with
generally speaking WebWork 2 providing more features in areas, for better, for
worse.
Sean Gilligan wrote:
Don Brown wrote:
Sure, what's the question(s)?
Well, I was going to ask what the status of the WebWork/Struts merger
was, but I did my online research, first. In fact, I went ahead and
created a Wiki page for an SAF 2.0 implementation of the Blog UI and put
the links to the relevant Web Pages in the "Background Info and Links"
section:
http://rollerweblogger.org/wiki/Wiki.jsp?page=Proposal_VelocityToSAF2
I'm proposing that the Blog UI module of Roller be rewritten/refactored
to use a very lightweight implementation of SpringMVC to replace the
current use of VelocityServlet. The main benefits would be:
1) URL mapping will not longer be limited by web.xml (it can use the
SpringMVC HandlerMapping interface or, hopefully, the
SimpleUrlHandlerMapping implementation)
WebWork 2 defaults to using the FilterDispatcher, which accomplishes the same
task. It allows us to serve static content easily, like Javascript files, from
within the jar. In fact, WebWork in general is well attuned to allowing modules
to be completely self-contained in a jar, which is used to great effect by
applications like JIRA. JIRA allows you to upload a complex plugin, called
macros, by uploading a jar that can have static content, templates, code, and
configuration files.
Furthermore, WebWork 2 has something similar to the HanderMapping called the
ActionMapper. This lets you have full control of how actions, namespaces, and
even parameters are coded into a URL. For example, Patrick has developed a
restful action mapper that lets you map the URL:
/books/view/book/Foo/chapter/1
to
Namespace: /books
Action: view
Parameters: book="Foo", chapter=1
2) View independence through the SpringMVC View interface.
In WebWork 2, this is called a Result, and we have builtin support for JSP,
Velocity, Freemarker, JFreeChart, Jasper, XSLT, and a few others.
I spent a few hours refactoring in Eclipse and it was pretty easy to
split the PageServlet into a PageController and a RollerVelocityView.
Since SpringMVC Controllers and View use HttpServletRequest and
HttpServletResponse, the refactoring is fairly simple.
I've posted a diff to the Wiki on this page:
http://rollerweblogger.org/wiki/Wiki.jsp?page=Proposal_VelocityToSpringMVC
(although the diffs between PageServlet.java and PageController.java
don't show because I renamed the file)
I've spent a little time looking at WebWork 2.x and it seems to me that
it requires a greater degree of abstraction from Servlets and
HttpServletRequest/Response. That is why, at this point, I believe
SpringMVC would be a more natural choice for the BlogUI.
WebWork 2 also gives you access to the HTTP objects if you feel you need them
either through ServletActionContext.getRequest() or implementing RequestAware if
you prefer an IoC approach. I'd imagine the migration from Servlet to
Controller looks about what migrating to a simple Action would look like.
So the question is: Is there a similar "lightweight" architecture we
could use based upon WebWork/SAF2.0?
I'm not sure how you could get much more lightweight than WebWork 2, so perhaps
a list of extra steps or hassles WebWork 2 would make you go through would help
me answer that question better.
I've been talking about WebWork 2 so far, because if you did this today, that is
what I'd recommend. Struts Action Framework 2 is starting with the WebWork
2.2.2 codebase and we are hoping to get a beta release out by JavaOne and GA by
August, which might be too long for your plans. We are taking migration very
seriously both for Struts and WebWork 2 applications, so if you used WebWork 2
today, the amount of work to switch, particularly in your case, would take
probably just a few minutes.
I've created a Wiki page for a SAF 2.0 implementation, so it would be
great if you or anyone else (Matt?) would be willing to fill in some
details there.
If this is about Roller moving to WebWork/SAF 2.0, I actually put in a
JavaOne proposal to talk about my experiences migrating Roller to use
SAF 2.0, but it wasn't accepted :)
Do you have any URLs, powerpoints, etc. that you put together? How far
did you get? Is it something you might submit to the Roller project?
No, the plan was if the talk got accepted, that's what I'd be doing for the
months leading up to it. Again, we want to make sure SAF 2 is an easy migration
for Struts apps, and I was thinking that the talk would be good to press the
issue :)
That said, if Roller is considering upgrading to Struts Action 2, I'd be more
than happy to help out, as it would help us focus our migration tools
simultaneously.
Hope that helps,
Don
Thanks,
Sean