Grails App-Info plugin

I released a new Grails plugin today, app-info. This plugin exposes a lot of internal information for a Grails application. Most of the code for this plugin dates back a long time and was originally mostly JSPs that I would copy into whatever application I was working on to give myself a view into what's going on. Over time as I started using Spring and Hibernate I added more pages to display that information, and it now also shows information about Grails too.

Click any of the images to see the full-size version in a new window.

Configuration

This plugin uses the Dynamic Controller plugin to modularize the controller actions as mixins. There are several of them and if there are some you don't want or need, you can exclude them. None are configured by default - that has to be done in your application's grails-app/conf/Config.groovy file. Here's the configuration from the sample application (download link at the end):

grails.plugins.dynamicController.mixins = [
   'com.burtbeckwith.grails.plugins.appinfo.IndexControllerMixin':       'com.burtbeckwith.appinfo_test.AdminManageController',
   'com.burtbeckwith.grails.plugins.appinfo.HibernateControllerMixin':   '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'
]

With this configuration all of the URLs will start with http://localhost:8080/appname/adminManage. My preference is to re-map these in grails-app/conf/UrlMappings.groovy to http://localhost:8080/appname/admin/manage since I want the administration parts of the application under /admin/**. This is optional but if you want to do this see the configuration in the sample app.

Note: This plugin exposes a lot of information about your application so you're strongly recommended to use a security plugin and guard these URLs. The sample application uses the Spring Security Core plugin but you're free to restrict access however you like, and optionally not even include this in your production war.

Usage


The Attributes menu has three entries:

Application

Displays all application-scope attributes from the ServletContext

Request

Displays all request-scope attributes from the current HttpServletRequest. Since this is for the current request, it's mostly useful to see what's available in a typical request.

Session

Displays all session-scope attributes from the current HttpSession. Since this is for the current request, it's mostly useful to see what's available in a typical session.


The Properties menu has three entries:

Data Source

A read/write view of the DataSource bean. Depending on the DataSource implementation, changing an attribute will take effect immediately and reset the connection pool

Grails Properties

Read-only view of the Grails Configuration.

System Properties

Read/write view of system properties. You can alter current properties or add new ones.


The Info menu has five entries:

Controllers

All controllers, plus links to all actions

Logging

Has comboboxes for all loggers to change the log level at runtime. Also has a text field to register a new Logger and its level.

Also includes a reverse-engineered log4j.xml based on the in-memory Log4j configuration. This is an estimate, so it may not be 100% accurate. But if you're having logging configuration issues and are familiar with the log4j.xml format, this can be convenient for diagnosing how things are misconfigured.

Memory

Graphs describing memory usage. Also has an action to trigger explicit garbage collection.

Sessions

Displays all current sessions and session-scope variables with a link to invalidate the session. This is enabled by default; to disable set grails.plugins.appinfo.useContextListener = false in grails-app/conf/Config.groovy

Spring Beans

Spring bean information for all beans in the "main" context and the parent context


The Hibernate menu has five entries and several sub-actions

Overview

  • Properties
  • Mappings Info
  • Imports
  • Auxiliary Database Objects
  • Named Queries
  • Named SQL Queries
  • TypeDefs
  • Filter Definitions

Entity Graphs

ER-style graphs of all Hibernate classes with relationships.

Table Graphs

ER-style graphs of all tables with relationships.

Caching

2nd-level cache information for StandardQueryCache, UpdateTimestampsCache, and all domain class caches.

Also has links to clear the cache and display usage graphs

Statistics

  • General Hibernate statistics
  • Links for statistics for each domain class
  • Links for statistics for each collection
  • Links for statistics for cached queries

Combos

On each page there are three combo boxes. The Tables combo box lists all database tables and selecting one displays detailed information for that table

The Entities combo box lists all entities (domain classes, JPA-annotated Java classes, and hbm.xml-mapped classes) and selecting one displays detailed information for each one

The hbm.xml combo box lists all entities and selecting one displays the reverse-engineered hbm.xml that would have created the equivalent entity. This is useful if you're having GORM mapping issues and want to see what the Hibernate configuration is

Sample Project

You can download a preconfigured sample application here

The /admin/** URLs in the sample app are restricted to users with ROLE_ADMIN. There's one user configured in BootStrap.groovy with username 'admin' and password 'password' with ROLE_ADMIN, so you can use that to authenticate.

16 Responses to “Grails App-Info plugin”

  1. Stephane Maldini
    July 17th, 2010 03:31
    1

    Oh damn ! What a wonderful stack of admin utils. 1 billion congratz Burt

  2. Jon Chase
    July 17th, 2010 05:57
    2

    This looks amazing!

    I’ve got a bunch of disparate admin pages that I’ve carried with me between projects as well, but this plugin might just replace all of them.

    Keep up the great work! :D

  3. Dan Lynn
    July 17th, 2010 16:18
    3

    Very very cool. Thanks Burt!

  4. Andre
    July 18th, 2010 14:52
    4

    Awesome!

  5. Ray Tayek
    July 18th, 2010 22:46
    5

    opening with winzip gets a: “error reading header …”

    works on linux

  6.   Nuevo plugin: App-Info (inglés) - Observatorio de Grails
    July 19th, 2010 03:06
    6

    [...] información sobre Grails App-Info plugin (traducido al [...]

  7. Lubos Pochman
    July 19th, 2010 08:01
    7

    Fantastic plugin! Thanks Burt, had no problem with install or dependencies! The only suggestion I would have is to start home page (/admin/manage or /adminManage) with something more than menu, maybe Application Scope Variables.

    Thanks Burt!

  8. Giri Pottepalem
    July 19th, 2010 08:09
    8

    This will be very useful plug-in and saves lot of time in adding admin capabilities to the application.

  9. docent.klekot
    July 20th, 2010 04:18
    9

    this looks great! Thanks a lot.

  10. Burts new app-info plugin
    July 20th, 2010 08:57
    10

    [...] http://burtbeckwith.com/blog/?p=344 [...]

  11. Burt’s new app-info plugin
    July 20th, 2010 10:23
    11

    [...] http://burtbeckwith.com/blog/?p=344 [...]

  12. Ettiene
    July 20th, 2010 15:50
    12

    Dude… must say excellent work… Thanks!

  13. Kai
    July 21st, 2010 15:12
    13

    Excellent job Burt. We are adding this plugin as soon as we can for sure.

  14. Rodrigo Rosenfeld Rosas
    July 30th, 2010 13:49
    14

    Is the source-code available somewhere?

  15. Burt
    July 30th, 2010 14:02
    15

    @Rodrigo the plugin zips contain the source and are compiled with your application code. For the full source code, most plugins keep their source in SVN at http://plugins.grails.org/ and this one is at http://plugins.grails.org/grails-app-info/

  16. Rodrigo Rosenfeld Rosas
    July 30th, 2010 14:13
    16

    Thank you, Burt.

Leave a Reply