changeset 1065:cf421645a2d3

Made cache statistics available as MBeans (eg in JConsole). gnv-artifacts/trunk@1157 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 04 Jun 2010 08:47:52 +0000
parents 026b936290bc
children bf9e95141ce0
files gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/cache/CacheFactory.java
diffstat 2 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Thu Jun 03 16:12:35 2010 +0000
+++ b/gnv-artifacts/ChangeLog	Fri Jun 04 08:47:52 2010 +0000
@@ -1,3 +1,9 @@
+2010-06-04  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	* src/main/java/de/intevation/gnv/artifacts/cache/CacheFactory.java: The
+	  ehcache CacheManager and the MBeanServer of the JVM are connected so that
+	  the statistics of the cache is available as MBean in JConsole.
+
 2010-06-03  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	* src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java:
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/cache/CacheFactory.java	Thu Jun 03 16:12:35 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/cache/CacheFactory.java	Fri Jun 04 08:47:52 2010 +0000
@@ -1,8 +1,14 @@
 package de.intevation.gnv.artifacts.cache;
 
+import java.lang.management.ManagementFactory;
+
+import javax.management.MBeanServer;
+
 import net.sf.ehcache.Cache;
 import net.sf.ehcache.CacheManager;
 
+import net.sf.ehcache.management.ManagementService;
+
 import org.apache.log4j.Logger;
 
 import de.intevation.gnv.geobackend.base.query.cache.CacheCleaner;
@@ -75,6 +81,11 @@
         if (cacheManager == null) {
             cacheManager = new CacheManager(configurationFileName);
             cacheManager.addCache(CACHENAME);
+
+            MBeanServer beanServer = ManagementFactory.getPlatformMBeanServer();
+            ManagementService.registerMBeans(
+                cacheManager, beanServer, false, false, false, true);
+
             this.cacheCleaner = new ThematicDataCacheCleaner();
             this.cacheCleaner.start();
         }

http://dive4elements.wald.intevation.org