Modified to support Grails 2.0 and up.