The Grails app-info-hibernate plugin

The original app-info plugin had support for displaying lots of information about your Grails application, and several pages for Hibernate information and graphs. The Hibernate features ended up being about half of the plugin, so originally I wanted to split out the Hibernate features into a separate plugin. This didn’t work because I wasn’t able to get the GSPs rendered; at the time it wasn’t possible to use a plugin attribute for the render method to tell Grails where to find the controller mixin’s GSPs.

When Grails 2.0 was released my hand was forced though, since there wasn’t a version of the Hibernate Tools library that I use to generate table and entity graphs which worked with the updated version of Hibernate that Grails now uses. I was able to create a mostly-working version of the db-reverse-engineer plugin which also uses Hibernate Tools by forking the Gant script in its own JVM and using a different Hibernate jar, but that wasn’t possible in the app-info plugin because the functionality is part of the runtime, not just a script. So I removed the Hibernate features with plans to create an app-info-hibernate plugin once there was a compatible Hibernate Tools jar; I wrote about this here.

Fortunately there is finally a “CR1″ version of the Hibernate Tools library in Maven Central, and in my testing I discovered that the plugin attribute does work in the Grails 2.0 render method, so I finished up the work for the plugin and released it today. I also released an update of the db-reverse-engineer plugin which uses the updated library and no longer needs the hackish workaround of forking a new process; install version 0.5 by adding compile ':db-reverse-engineer:0.5' to your BuildConfig.groovy.


Using the plugin is very similar to what I described in the original blog post. Add the plugin to BuildConfig.groovy:

plugins {
   ...

   compile ':app-info-hibernate:0.2'
}

(that there’s no need to add the app-info plugin since it will be transitively installed) and configure the grails.plugins.dynamicController.mixins map in Config.groovy:

grails.plugins.dynamicController.mixins = [
   'com.burtbeckwith.grails.plugins.appinfo.IndexControllerMixin':
      'com.burtbeckwith.appinfo_test.AdminManageController',

   'com.burtbeckwith.grails.plugins.appinfo.Log4jControllerMixin' :
      'com.burtbeckwith.appinfo_test.AdminManageController',

   'com.burtbeckwith.grails.plugins.appinfo.SpringControllerMixin' :
      'com.burtbeckwith.appinfo_test.AdminManageController',

   'com.burtbeckwith.grails.plugins.appinfo.MemoryControllerMixin' :
      'com.burtbeckwith.appinfo_test.AdminManageController',

   'com.burtbeckwith.grails.plugins.appinfo.PropertiesControllerMixin' :
      'com.burtbeckwith.appinfo_test.AdminManageController',

   'com.burtbeckwith.grails.plugins.appinfo.ScopesControllerMixin' :
      'com.burtbeckwith.appinfo_test.AdminManageController',

   'com.burtbeckwith.grails.plugins.appinfo.ThreadsControllerMixin' :
      'com.burtbeckwith.appinfo_test.AdminManageController',

   'com.burtbeckwith.grails.plugins.appinfo.hibernate.HibernateControllerMixin' :
      'com.burtbeckwith.appinfo_test.AdminManageController',

   'app.info.custom.example.MyConfigControllerMixin' :
      'com.burtbeckwith.appinfo_test.AdminManageController'
]

One thing to be aware of is that the HibernateControllerMixin package has changed; it’s now in the com.burtbeckwith.grails.plugins.appinfo.hibernate package.

Note that due to some issues in the updated grails.org site, the app-info plugin page isn’t editable, so it’s out of date, and there’s no plugin page yet for the app-info-hibernate plugin. It will be at http://grails.org/plugin/app-info-hibernate when the issues are resolved. You can install the plugin, it’s just not viewable in the plugin portal.


You can download a sample application that uses the plugin here.

6 Responses to “The Grails app-info-hibernate plugin”

  1. David says:

    Where can I download the source?

  2. David says:

    Also, I cannot see the generated hbm files, which is why I installed the plugin :(

    In IE I don’t see anything changing in the lower frame when I select the domain object in the hbm.xml dropdown.

    In Chrome, the lower frame does change, the and url changes, but the text area is empty.

    What am I missing?

    • Burt says:

      I updated the post with a link to a sample application – see if that works for you. Be sure to use version 0.2 of the plugin – I made a few changes related to dependencies (unlikely to affect what you’re seeing though).

  3. James says:

    Hello Burt,

    Great Plugins! Thanks! I’m having the same issues as David. Textarea in lower frame stays empty.

    I downloaded your demo app to take a look, but I cannot get past the login. Where am I supposed to find those credentials?

    Help is MUCH appreciated. Thanks & thank you for sharing your work.

    • James says:

      I just side-stepped the security by changing IS_ADMIN to IS_AUTHENTICATED_ANONYMOUSLY. Same thing happens; The textarea just stays blank.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.