Wednesday, February 28, 2007

Gettin' Groovy

My client site uses an Object-Oriented DB. For months now, the only way to "see" the data was either a wretched DB "inspector" from the vendor or to debug the extensive server application.

I had been experimenting with Groovy a bit and decided to give it a try. In a rare flash of tactical insight (particularly step 1), I did the following:

  • The server apps are started via Ant. I hacked the Ant XML file so that it wrote the classpath variable to the console. The line was enormous but, in theory, would contain almost everything I needed.
  • I set the classpath in a "bat" file along with the Groovy jar, and set-up a windows cmd shell.
  • I started to cut-n-paste some of the DB config code into a Groovy script.
  • There was definitely a learning curve (mostly classpath/import issues), but before long, I was reading and writing directly to the OODB, using precisely the same Java classes that our app uses. Each example script was about 30 lines long.
'Twas a pure moment of Code to Joy. Beethoven was playing throughout my cube.... True, it wouldn't have been that much different to do in straight Java, but (a) there's just something "inviting" about the scripting philosophy and (b) tellingly, no one had done it for months (re: Java).

Final score: Groovy 1 OODB 0

No comments: