diff --git a/SpringcacheGrailsPlugin.groovy b/SpringcacheGrailsPlugin.groovy index 7a01255..6844ed0 100644 --- a/SpringcacheGrailsPlugin.groovy +++ b/SpringcacheGrailsPlugin.groovy @@ -23,6 +23,8 @@ import org.springframework.web.filter.DelegatingFilterProxy import grails.plugin.springcache.aop.* import grails.plugin.springcache.web.* import org.springframework.cache.ehcache.* +import java.lang.management.ManagementFactory +import net.sf.ehcache.management.ManagementService class SpringcacheGrailsPlugin { @@ -134,6 +136,18 @@ class SpringcacheGrailsPlugin { for (tagLibClass in application.tagLibClasses) { decorator.decorate(tagLibClass, applicationContext."${tagLibClass.fullName}") } + + def jmxConfig = application.config.springcache.jmx + if (jmxConfig) { + def springcacheCacheManager = applicationContext.getBean("springcacheCacheManager") + ManagementService.registerMBeans(springcacheCacheManager, ManagementFactory.platformMBeanServer, + jmxConfig.cacheManager, + jmxConfig.cache, + jmxConfig.cacheConfiguration, + jmxConfig.cacheStatistics + ) + } + } def onChange = { event -> diff --git a/TODO.md b/TODO.md index 60d3776..9e9ebe5 100644 --- a/TODO.md +++ b/TODO.md @@ -7,7 +7,6 @@ ## General * convert annotation classes to Groovy so they can use null defaults -* expose caching statistics (JMX?) * support reloading via onChange and onConfigChange [GRAILSPLUGINS-1825][1825] ## Controller caching @@ -27,4 +26,4 @@ * cacheable version of g:render? -[1825]:http://jira.codehaus.org/browse/GRAILSPLUGINS-1825 \ No newline at end of file +[1825]:http://jira.codehaus.org/browse/GRAILSPLUGINS-1825 diff --git a/application.properties b/application.properties index 1f0c895..3e0ab43 100644 --- a/application.properties +++ b/application.properties @@ -1,4 +1,5 @@ #Grails Metadata file -#Tue Dec 21 13:35:56 GMT 2010 +#Mon Nov 21 15:44:22 CET 2011 app.grails.version=1.3.7 app.name=springcache +plugins.tomcat=1.3.7 diff --git a/src/docs/guide/1.2. Release Notes.gdoc b/src/docs/guide/1.2. Release Notes.gdoc index fb6e250..a83f185 100644 --- a/src/docs/guide/1.2. Release Notes.gdoc +++ b/src/docs/guide/1.2. Release Notes.gdoc @@ -1,3 +1,7 @@ +h4. 1.3.2 + + * exposing ehcache to JMX + h4. 1.3.1 * Fixes compilation problem on recent Groovy versions "GRAILSPLUGINS-2820":http://jira.codehaus.org/browse/GRAILSPLUGINS-2820 diff --git a/src/docs/guide/7. Cache Configuration.gdoc b/src/docs/guide/7. Cache Configuration.gdoc index 5c6a2fa..de8aa8c 100644 --- a/src/docs/guide/7. Cache Configuration.gdoc +++ b/src/docs/guide/7. Cache Configuration.gdoc @@ -53,3 +53,21 @@ springcache { Under the hood this is simply setting up @EhCacheFactoryBean@ instances in the Spring context, so it is up to you whether you prefer to use @resources.groovy@ or @Config.groovy@ there is not much difference. The properties shown are just examples, see the "EhCacheFactoryBean":http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/cache/ehcache/EhCacheFactoryBean.html documentation for full details of all the properties you can set. + + +h3. exposing ehcache to JMX + +Ehcache is already prepared to expose itself to JMX. To enable this use the following snippet in @grails-app/conf/Config.groovy@: + +{code} +springcache { + jmx { + cacheManager = true + cache = true + cacheConfiguration = true + cacheStatistics = true + } +} +{code} + +For details, see [Ehcache's JMX manual|http://ehcache.org/documentation/operations/jmx]. \ No newline at end of file