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):
'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.
About Burt Beckwith
Burt Beckwith is a Java and Groovy developer with over ten years of experience in a variety of industries including biotech, travel, e-learning, social networking, and financial services. For the past three years he's been working with Grails and Groovy full-time. Along the way he's created over fifteen Grails plugins and made significant contributions to several others. He was the technical editor for Grails in Action.
More About Burt »NFJS, the Magazine
2011-07-01 00:00:00.0 Issue Now AvailableOn Eloquent Conversations, Part 1
by Raju GandhiMongoDB - Why and How?
by Peter BellSimple & Easy Guide to Types in Scala
by Daniel HinojosaAjax Library Smackdown: Dojo vs. YUI
by Nathaniel Schutta



















