Wednesday, September 12, 2007

Grails to the test...

I've started working on this new project, a systemweb that enables me to monitor some of the things going on in our big super webapp.
The project is for admins only so for a change the focus will be on functional features instead of graphical features. Good start so far.

I very much like the idea of 'convention over configuration' (anyone would after working 1,5 years with Spring. Nothing bad about Spring but configuration wise it has become somewhat of a monster) so I turned to the new kids on the block: (J)Ruby on Rails and Grails.
I've seen both Graeme Rocher (Grails man) and Charles Nutter (JRuby man) talking about their own framework and must say that it did not make the choice easier. Both frameworks offer a great deal of features so in the end it would come to my personal preference to tilt the scales.

Since I'm a Java developer and I'm still a bit time-bound, which didn't give me much time to learn a complete new language I chose Grails. This way I could still do Java, which I love and do Groovy scripting too.
Actually as Graeme Rocher pointed out: Groovy IS Java so that makes things a whole lot easier.

Eager as I am to get started I created my grails project and my first controller, the ClientDomainController. It will manage my... client domains.
Then it got interesting. Instead of using the grails domain class structure I wanted to use our existing libraries. All the stuff I needed was already there.
In the manuals I could only find stuff about using the Grails domain classes so I started thinking: The only thing I would do in Spring to use a library would be importing it in my Spring file...

The import looks like this:

<import resource="classpath*:spring-common.xml" />
<import resource="classpath*:spring-business.xml" />


First I tried the spring.resources.xml file but that didn't work so I tried the applicationContext.xml file and...

VĂ²ila! Now I have access to all my existing managers, domain classes, etc...
Great thing is that now I don't have to worry about my database stuff either. So for all this I only added 2 lines of xml to a file... sounds good to me.