geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r106697 - in geronimo/trunk/applications/jmxdebug/src: java/org/apache/geronimo/jmxdebug/web/beanlib java/org/apache/geronimo/jmxdebug/web/velocity webapp
Date Sat, 27 Nov 2004 08:58:01 GMT
Author: djencks
Date: Sat Nov 27 00:58:00 2004
New Revision: 106697

URL: http://svn.apache.org/viewcvs?view=rev&rev=106697
Log:
use gbeans not mbeans
Added:
   geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/GBeanInfoHelper.java
      - copied, changed from r106688, geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/MBeanInfoHelper.java
   geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/KernelHelper.java
      - copied, changed from r106688, geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/MBeanServerHelper.java
Removed:
   geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/AttributeData.java
   geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/MBeanInfoHelper.java
   geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/MBeanServerHelper.java
Modified:
   geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/velocity/DebugServlet.java
   geronimo/trunk/applications/jmxdebug/src/webapp/mbeaninfo.vm
   geronimo/trunk/applications/jmxdebug/src/webapp/mbeanstack.vm

Deleted: /geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/AttributeData.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/AttributeData.java?view=auto&rev=106696
==============================================================================

Copied: geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/GBeanInfoHelper.java
(from r106688, geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/MBeanInfoHelper.java)
Url: http://svn.apache.org/viewcvs/geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/GBeanInfoHelper.java?view=diff&rev=106697&p1=geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/MBeanInfoHelper.java&r1=106688&p2=geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/GBeanInfoHelper.java&r2=106697
==============================================================================
--- geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/MBeanInfoHelper.java
(original)
+++ geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/GBeanInfoHelper.java
Sat Nov 27 00:58:00 2004
@@ -18,23 +18,20 @@
 package org.apache.geronimo.jmxdebug.web.beanlib;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanServer;
 import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import javax.management.RuntimeMBeanException;
+
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.management.State;
 
 /**
  * Simple helper bean for dealing with MBeanInfo.  Helps dodge such
@@ -43,16 +40,16 @@
  * 
  * @version $Rev$ $Date$
  */
-public class MBeanInfoHelper {
+public class GBeanInfoHelper {
     private final ObjectName objectName;
-    private final MBeanInfo info;
-    private final MBeanServer server;
+    private final GBeanData info;
+    private final Kernel kernel;
 
-    public MBeanInfoHelper(MBeanServerHelper kernelHelper, String name) throws Exception
{
-        server = kernelHelper.getKernel().getMBeanServer();
-        if (server != null) {
+    public GBeanInfoHelper(KernelHelper kernelHelper, String name) throws Exception {
+        kernel = kernelHelper.getKernel();
+        if (kernel != null) {
             objectName = new ObjectName(name);
-            info = server.getMBeanInfo(objectName);
+            info = kernel.getGBeanData(objectName);
         } else {
             objectName = null;
             info = null;
@@ -68,6 +65,14 @@
         return objectName.getDomain();
     }
 
+    public String getState() {
+        try {
+            return State.toString(((Integer)kernel.getAttribute(objectName, "state")).intValue());
+        } catch (Exception e) {
+            return ("Could not get state: " + e.getMessage());
+        }
+    }
+
     /**
      * Returns the key properties and values a list of
      * maps, w/ 'key' and 'value' as entryies in each
@@ -98,57 +103,26 @@
         return l;
     }
 
-    public String getDescription() {
-        return info.getDescription();
-    }
-
     public String getClassName() {
-        return info.getClassName();
+        return info.getGBeanInfo().getClassName();
     }
 
     public SortedMap getAttributes() {
-        TreeMap attributes = new TreeMap();
-
-        MBeanAttributeInfo[] arr = info.getAttributes();
-
-        for (int i = 0; i < arr.length; i++) {
-            MBeanAttributeInfo attribute = arr[i];
-            String name = attribute.getName();
-
-            if ((!attribute.isReadable() && !attribute.isWritable()) || name.startsWith("$"))
{
-                // hide attributes that are not readable or writable or start with a '$'
-                continue;
+        TreeMap attributes = new TreeMap(info.getAttributes());
+        for (Iterator iterator = attributes.entrySet().iterator(); iterator.hasNext();) {
+            Map.Entry entry = (Map.Entry) iterator.next();
+            if (entry.getValue() == null) {
+                entry.setValue("(null)");
             }
-
-            Object value = null;
-            if (attribute.isReadable()) {
-                try {
-                    value = server.getAttribute(objectName, name);
-                } catch (MBeanException e) {
-                    e.printStackTrace();
-                } catch (AttributeNotFoundException e) {
-                    e.printStackTrace();
-                } catch (InstanceNotFoundException e) {
-                    e.printStackTrace();
-                } catch (ReflectionException e) {
-                    e.printStackTrace();
-                } catch (RuntimeMBeanException rme) {
-                    rme.printStackTrace();
-                }
-            }
-
-            try {
-                AttributeData attributeData = new AttributeData(attribute, value, server.getClassLoaderFor(objectName));
-                attributes.put(name, attributeData);
-            } catch (Exception e) {
-                // ignore; just hide weird attributes
+            if (entry.getValue() instanceof Object[]) {
+                entry .setValue(Arrays.asList((Object[])entry.getValue()));
             }
         }
 
         return attributes;
     }
 
-    public MBeanOperationInfo[] getOperationInfo() {
-        return info.getOperations();
+    public Set getOperationInfo() {
+        return info.getGBeanInfo().getOperations();
     }
 }

Copied: geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/KernelHelper.java
(from r106688, geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/MBeanServerHelper.java)
Url: http://svn.apache.org/viewcvs/geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/KernelHelper.java?view=diff&rev=106697&p1=geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/MBeanServerHelper.java&r1=106688&p2=geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/KernelHelper.java&r2=106697
==============================================================================
--- geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/MBeanServerHelper.java
(original)
+++ geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/KernelHelper.java
Sat Nov 27 00:58:00 2004
@@ -34,10 +34,10 @@
  *
  * @version $Rev$ $Date$
  */
-public class MBeanServerHelper {
+public class KernelHelper {
     private final Kernel kernel;
 
-    public MBeanServerHelper() {
+    public KernelHelper() {
         kernel = Kernel.getSingleKernel();
     }
 
@@ -50,8 +50,8 @@
      *
      * @return Collection of InstanceObjects
      */
-    public Collection getMBeans() {
-        return getMBeans("*:*");
+    public Collection getGBeanNames() {
+        return getGBeanNames("*:*");
     }
 
     /**
@@ -60,7 +60,7 @@
      * @param filterString filter to use.  Defaults to *:* if null
      * @return Collection of InstanceObjects that match the filter
      */
-    public Collection getMBeans(String filterString) {
+    public Collection getGBeanNames(String filterString) {
         if (filterString == null) {
             filterString = "*:*";
         }
@@ -79,7 +79,7 @@
                 e.printStackTrace();
             }
         } else {
-            System.out.println("MBeanServerHelper : error : no mbean server");
+            System.out.println("KernelHelper : error : no mbean server");
         }
 
         return null;

Deleted: /geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/MBeanInfoHelper.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/MBeanInfoHelper.java?view=auto&rev=106696
==============================================================================

Deleted: /geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/MBeanServerHelper.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/MBeanServerHelper.java?view=auto&rev=106696
==============================================================================

Modified: geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/velocity/DebugServlet.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/velocity/DebugServlet.java?view=diff&rev=106697&p1=geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/velocity/DebugServlet.java&r1=106696&p2=geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/velocity/DebugServlet.java&r2=106697
==============================================================================
--- geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/velocity/DebugServlet.java
(original)
+++ geronimo/trunk/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/velocity/DebugServlet.java
Sat Nov 27 00:58:00 2004
@@ -24,8 +24,8 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.geronimo.jmxdebug.web.beanlib.MBeanInfoHelper;
-import org.apache.geronimo.jmxdebug.web.beanlib.MBeanServerHelper;
+import org.apache.geronimo.jmxdebug.web.beanlib.GBeanInfoHelper;
+import org.apache.geronimo.jmxdebug.web.beanlib.KernelHelper;
 import org.apache.velocity.VelocityContext;
 
 /**
@@ -57,7 +57,7 @@
 
         VelocityContext vc = new VelocityContext();
 
-        MBeanServerHelper kernelHelper = new MBeanServerHelper();
+        KernelHelper kernelHelper = new KernelHelper();
         vc.put("mbctx", kernelHelper);
         vc.put("encoder", new KickSunInHead());
         vc.put(OBJECT_NAME_FILTER_KEY, filterKey);
@@ -66,7 +66,7 @@
             vc.put("template", "nobean.vm");
         } else {
             try {
-                vc.put("beanInfo", new MBeanInfoHelper(kernelHelper, beanName));
+                vc.put("beanInfo", new GBeanInfoHelper(kernelHelper, beanName));
             } catch (Exception e) {
                 e.printStackTrace();
             }

Modified: geronimo/trunk/applications/jmxdebug/src/webapp/mbeaninfo.vm
Url: http://svn.apache.org/viewcvs/geronimo/trunk/applications/jmxdebug/src/webapp/mbeaninfo.vm?view=diff&rev=106697&p1=geronimo/trunk/applications/jmxdebug/src/webapp/mbeaninfo.vm&r1=106696&p2=geronimo/trunk/applications/jmxdebug/src/webapp/mbeaninfo.vm&r2=106697
==============================================================================
--- geronimo/trunk/applications/jmxdebug/src/webapp/mbeaninfo.vm	(original)
+++ geronimo/trunk/applications/jmxdebug/src/webapp/mbeaninfo.vm	Sat Nov 27 00:58:00 2004
@@ -20,7 +20,7 @@
     <b>State: </b>
   </td>
   <td>
-    $mbctx.getState($name)
+    $beanInfo.getState()
   </td>
 </tr>
 </table>
@@ -34,13 +34,13 @@
   <th>Value</th>
 </tr>
 
-#foreach($i in $beanInfo.getAttributes().values())
+#foreach($i in $beanInfo.getAttributes().entrySet())
 
-#set($name = $i.name)
+#set($name = $i.getKey())
 #if($name != "objectName" && $name != "statisticsProvider" && $name != "stateManageable"
&& $name != "eventProvider" && $name != "state" && $name != "startTime")
 <tr>
   <td>$name</td>
-  <td>$!i.value</td>
+  <td>$i.getValue()</td>
 </tr>
 #end
 

Modified: geronimo/trunk/applications/jmxdebug/src/webapp/mbeanstack.vm
Url: http://svn.apache.org/viewcvs/geronimo/trunk/applications/jmxdebug/src/webapp/mbeanstack.vm?view=diff&rev=106697&p1=geronimo/trunk/applications/jmxdebug/src/webapp/mbeanstack.vm&r1=106696&p2=geronimo/trunk/applications/jmxdebug/src/webapp/mbeanstack.vm&r2=106697
==============================================================================
--- geronimo/trunk/applications/jmxdebug/src/webapp/mbeanstack.vm	(original)
+++ geronimo/trunk/applications/jmxdebug/src/webapp/mbeanstack.vm	Sat Nov 27 00:58:00 2004
@@ -12,7 +12,7 @@
 #set($filterParam = $encoder.encode($ObjectNameFilter, "UTF-8"))
 #set($currentDomain = "")
 #set($i = 0)
-#set($mbeanList = $mbctx.getMBeans($ObjectNameFilter))
+#set($mbeanList = $mbctx.getGBeanNames($ObjectNameFilter))
 
 <hr/>
 

Mime
View raw message