[jboss-cvs] JBossCache/src/org/jboss/cache ...
Brian Stansberry
brian.stansberry at jboss.com
Mon Jun 4 18:54:52 EDT 2007
User: bstansberry
Date: 07/06/04 18:54:52
Modified: src/org/jboss/cache TreeCacheViewMBean.java
TreeCacheView.java
Log:
[JBCACHE-1065] TreeCacheView should just inject Cache
Revision Changes Path
1.5 +8 -2 JBossCache/src/org/jboss/cache/TreeCacheViewMBean.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TreeCacheViewMBean.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCacheViewMBean.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- TreeCacheViewMBean.java 22 May 2007 16:51:01 -0000 1.4
+++ TreeCacheViewMBean.java 4 Jun 2007 22:54:52 -0000 1.5
@@ -6,6 +6,8 @@
*/
package org.jboss.cache;
+import org.jboss.cache.jmx.CacheJmxWrapperMBean;
+
/**
* MBean interface.
@@ -22,7 +24,11 @@
void destroy() ;
- String getCacheService();
+ Cache getCache();
+
+ void setCache(Cache cache);
+
+ CacheJmxWrapperMBean getCacheService();
- void setCacheService(String cache_service) throws Exception;
+ void setCacheService(CacheJmxWrapperMBean cache_service);
}
1.26 +40 -39 JBossCache/src/org/jboss/cache/TreeCacheView.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TreeCacheView.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCacheView.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- TreeCacheView.java 30 May 2007 11:35:15 -0000 1.25
+++ TreeCacheView.java 4 Jun 2007 22:54:52 -0000 1.26
@@ -12,6 +12,7 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.jmx.CacheJmxWrapper;
+import org.jboss.cache.jmx.CacheJmxWrapperMBean;
import org.jgroups.View;
import javax.management.MBeanServer;
@@ -55,14 +56,14 @@
* data needs to be displayed, the underlying cache will be accessed directly.
*
* @author Bela Ban
- * @version $Revision: 1.25 $
+ * @version $Revision: 1.26 $
*/
public class TreeCacheView implements TreeCacheViewMBean
{
/**
* Reference to the CacheImpl MBean (the model for this view)
*/
- ObjectName cache_service = null;
+ CacheJmxWrapperMBean cache_service = null;
TreeCacheGui gui = null;
CacheSPI cache;
Log log = LogFactory.getLog(TreeCacheView.class);
@@ -71,12 +72,16 @@
public TreeCacheView() throws Exception
{
super();
- init(null);
}
- public TreeCacheView(String cache_service) throws Exception
+ public TreeCacheView(Cache cache) throws Exception
{
- init(cache_service);
+ setCache(cache);
+ }
+
+ public TreeCacheView(CacheJmxWrapper mbean) throws Exception
+ {
+ setCacheService(mbean);
}
@@ -109,45 +114,40 @@
{
}
- public String getCacheService()
- {
- return cache_service != null ? cache_service.toString() : null;
- }
- /**
- * @param cache_service
- * @throws Exception
- */
- public void setCacheService(String cache_service) throws Exception
+
+ public Cache getCache()
{
- init(cache_service);
+ return cache;
}
-
- void init(String cache_service) throws Exception
+ public void setCache(Cache cache)
{
- MBeanServer srv = null;
-
- if (cache_service != null)
+ this.cache = (CacheSPI) cache;
+ System.out.println("Cache " + cache);
+ if (cache != null)
{
- this.cache_service = new ObjectName(cache_service);
+ gui = new TreeCacheGui(this.cache);
}
else
{
- return;
+ gui = null;
+ }
}
- // is this the right way to get hold of the JBoss MBeanServer ?
- List servers = MBeanServerFactory.findMBeanServer(null);
- if (servers == null || servers.size() == 0)
- {
- throw new Exception("TreeCacheView.init(): no MBeanServers found");
- }
- srv = (MBeanServer) servers.get(0);
- log.info("init(): found MBeanServer " + srv);
- cache = (CacheSPI) srv.getAttribute(this.cache_service, "Cache");
- System.out.println("Cache " + cache);
- TreeCacheGui gui = new TreeCacheGui(cache);
+ public CacheJmxWrapperMBean getCacheService()
+ {
+ return cache_service;
+ }
+
+ /**
+ * @param cache_service
+ * @throws Exception
+ */
+ public void setCacheService(CacheJmxWrapperMBean cache_service)
+ {
+ this.cache_service = cache_service;
+ setCache(cache_service == null ? null : cache_service.getCache());
}
@@ -265,9 +265,10 @@
cache.getNotifier().addCacheListener(new MyListener());
log.info("registering the cache as " + mbean_name);
- srv.registerMBean(new CacheJmxWrapper(cache), new ObjectName(mbean_name));
+ CacheJmxWrapper mbean = new CacheJmxWrapper(cache);
+ srv.registerMBean(mbean, new ObjectName(mbean_name));
- cache.start();
+ mbean.start();
Runtime.getRuntime().addShutdownHook(new ShutdownThread(cache));
@@ -278,7 +279,7 @@
// cache.put("/a/b1/chat2", null);
// cache.put("/a/b1/chat5", null);
- demo = new TreeCacheView(mbean_name);
+ demo = new TreeCacheView(mbean);
demo.create();
demo.start();
if (start_directory != null && start_directory.length() > 0)
@@ -366,7 +367,7 @@
private static final int VAL_COL_WIDTH = 300;
- public TreeCacheGui(CacheSPI cache) throws Exception
+ public TreeCacheGui(CacheSPI cache)
{
this.cache = cache;
More information about the jboss-cvs-commits
mailing list