Posts Tagged ‘groovy’

Enterprise ready situational applications

Friday, February 6th, 2009

Where I was at: I quickly needed to expose some information. So using my laptop I created some Project Zero services written in Groovy that exposed the information via JSON and some pretty charts. My laptop is constantly in and out of its docking station. So in order to make the information available I cloned the Project Zero setup on a server and scp’d the changes across whenever I made local updates. All was fine.

Where I got to: A colleague then needed to create some additional services based on some of the work I had already done. So they cloned the Project Zero setup to their laptop and scp’d across any changes they made to the server. So as you can imagine, at this point we got into the position where we were occassionally overwriting each others updates on the server image. We needed change management.

Where I’m at today: I brought in Rational Team Concert (RTC) to act as a source code repository and change management environment for the Project Zero code. Into RTC I installed the codehaus Groovy plugin for Eclipse to provide me with Groovy syntax highlighting. A quick ant script later and I was able to deploy all the changes to the server on demand. Not stopping there, I decided that I was also fed up of breaking existing services when I was hacking away at the code. So with RTC being built on Eclipse I knew that JUnit came bundled by default. So, with a quick implementation of HTTP requests using the HttpURLConnection class (which is also bundled with Java) I then had a nice JUnit test suite to (literally) give me the green light before I check any changes in. Not only this, but my colleague then synchronized the changes into their RTC client where it picked up the JUnit tests and was able to run them on their laptop.

Project Zero, Groovy, Rational Team Concert & JUnit – what a combination. (and it puts me in a great position for TDD also!)

Where I’m at tonight: At a bar in Edinburgh, warming up for the big game on Sunday. Come on the reds!!!

Bookmark and Share

Feeling not so groovy

Sunday, December 14th, 2008

In my previous post, I mentioned I’ve started writing some scripts in Groovy. All was well until I wanted to persist data between tasks using JSON. The plan is to have a cron job that extracts data from a source and encodes it in a JSON file. I’ll then have a Project Zero application providing a service which when invoked would load the JSON data and return a summary of the data.

The good news… Project Zero has excellent built in JSON support through the zero.json.Json.decode and zero.json.Json.encode methods – which are amazing powerful and simple.

The bad news… When it comes to command line Groovy from groovy.codehaus.org, there doesn’t appear to be any built in support – bah!

So, using Groovy’s ability to use work with standard Java classes I trawled around for a Java JSON implementation. There’s a bunch listed on the www.json.org page, but having looked at a few none of them appear to be as simple as the Project Zero version.

The one that stood out was json-lib.sourceforge.net, but the number of dependencies it has on jars that have to be downloaded from external projects is mind boggling.

I tried importing the Project Zero jar files into my project to see if I could use the libraries they supply. But I soon discovered that it relies heavily on a running Project Zero environment. So no luck there either.

Surely it can’t be this difficult to have some simple JSON utility functions in Groovy. Right now I’m contemplating writing my own.

Bookmark and Share

println “Hello World”

Thursday, December 4th, 2008

Having spent most of my time testing on the mainframe, I’ve spent little of that time actually writing command lines scripts for tests (other than some Unix System Services work). Now that’s not to say I’m not completely familiar with scripting since my primary work station has been running Linux for a considerable time.

However, recently I needed to a little more advanced scripting on my Linux machine. So it was at this point I thought “which scripting language should I pick up and use?”. Obviously there’s a decent selection to choose from: Perl, Python, Ruby, Groovy, others (including Rexx).

In the end I settled on Groovy due to my years of experience in writing Java applications, plus Project Zero provides Groovy support.

With my first script in mind I set down to write and learn on the fly. After getting my head around the new syntax I found myself making progress. Also it’s quite nice being able to drop down to the Java syntax and use utility classes that you know to exist and are already familiar with. I know I’m not writing the prettiest Groovy code at the moment, but the way I see it is scripting languages are there for getting things done. And in one afternoon I picked up Groovy, installed the Eclipse plugin for it, and created a working script to do exactly what I needed. I was happy.

I have this niggling thought though… if I get in to Groovy, will it confuse the hell out of me when I go back to pure Java?

Bookmark and Share