Skip to content
This repository was archived by the owner on Sep 26, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions SpringcacheGrailsPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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 ->
Expand Down
3 changes: 1 addition & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,4 +26,4 @@

* cacheable version of g:render?

[1825]:http://jira.codehaus.org/browse/GRAILSPLUGINS-1825
[1825]:http://jira.codehaus.org/browse/GRAILSPLUGINS-1825
3 changes: 2 additions & 1 deletion application.properties
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions src/docs/guide/1.2. Release Notes.gdoc
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 18 additions & 0 deletions src/docs/guide/7. Cache Configuration.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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].