On the Spring forum we've been having a lively discussion about AOP support for scripted beans. Rick Evans has said the issues are not fundamental, and that he would be addressing them in the next few weeks.
I find this quite exciting. I'm really looking forward to a day when I can start my application server and just code. I'd really like to get rid of most, if not all, of the restarts.
(NB: For the latest on the subject see: Groovy Works.
I worked with using Spring to instantiate the action beans today, and that didn't go too far. I started getting an exception from AspectJ. (See thread on the Spring forum.)
So, I got to thinking. What if I created the GroovyClassLoader in Struts 2 prior to initializing the Spring context, and make the GroovyClassLoader the parent of the Spring context. This works! Finally something that works. It's not really enough though, and it's very cludgy. I would have to have two source trees, one of Groovy files that need to be compiled ahead of time, and one of others that are compiled and loaded at run time. That would make for a messy project in my eyes.
As announced on the Struts Users mailing list, Struts 2 release 2.0.6 has been given the "General Availability" thumbs up by the Struts developers.
This is the culmination of a lot of work by the Struts developers in bringing the WebWork code base into the Apache process and evolving it to create an elegant extensible framework. Congratulations to the Struts developers.
I've been working with Struts 2 since the 2.0.1-SNAPSHOT, and have found it to be a great framework. Go check it out.
See latest update: Groovy Works
A further update is available here.
Last week I started implementing my Struts 2 actions in Groovy. After a few days I decided I liked Groovy, but I wanted more. I didn't want to have to restart my servlet container every time I recompiled a class. I just wanted to be able to edit, save, and reload in my browser.
I researched using Spring to instantiate my actions, but Spring's scripting integration only supports singletons. So, to get around this I extended the Struts 2 Spring Plugin to integrate the GroovyClassLoader. That created problems with Spring's use of AspectJ's pointcuts to support declarative transactions. (Thread on Spring forum.)
My apologies. I had the site mis-configured, and not listing files attached to article to anonymous users. It's fixed now.
Well, I finally decided where they go. At least for the Quadran project. My package structure looks like this:
(N.B.: For the latest on Struts 2 and Groovy see: Groovy Works)
Actions in Struts 2 are POJO's. Actions also serve the same purpose of the ActionForm from Struts 1, storing all of the data submitted by your user. Additionally Struts 2 action classes store the information you wish to display back to your user. (NB: Struts 2 also supports a ModelDriven style, where the Action does not need to store this data, but the ideas are largely the same.)
Over the course of developing a Struts 2 application you will write a lot of accessors, setThis(String in), getThat(). Personally I'm sick of writing those methods. Yes, I know Eclipse could write them for me, but I don't like Eclipse, and I haven't taken the time to learn another IDE. I like my Unix shell, maven, screen and vi (vim), thank you very much.
I was working on a script today. I've been working on converting a lot of Perl scripts to Groovy over the past week. Anyway, I just removed all of the semi-colons from a script to see what it looks like. I like it. It makes it look different than Java. Try it. You might think the same.
Well, this week after hearing about Groovy and reading a bit about it I decided to take the plunge. I've grown tired of the get's and set's in Java code. It's all boiler plate repetitive, non-expressive junk. I've been listening to the Java Posse for quite some time, and all the talk about language level support of properties got to me. I checked out the Grooy Beans page and was sold.
As a proof of concept I started out writing some integration tests first. I used that as the test bed to get Groovy working with Maven. (I'll write more about that later.) Once I had that done I converted a Struts 2 Action that employed an Action class, a Model and a Query bean (to store the users input) into a single clear concise Groovy class. Three classes became one, rose in readability and it was quick. My Action, Model and Query class had a total of about 40 setters and getters. They're all gone now.