geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccard...@apache.org
Subject svn commit: r470623 [1/2] - in /geronimo/server/trunk/applications/console/geronimo-console-standard/src/main: java/org/apache/geronimo/console/jmxmanager/JMXManagerHelper.java webapp/WEB-INF/view/jmxmanager/viewJMXServer.jsp
Date Fri, 03 Nov 2006 01:14:19 GMT
Author: ccardona
Date: Thu Nov  2 17:14:18 2006
New Revision: 470623

URL: http://svn.apache.org/viewvc?view=rev&rev=470623
Log:
GERONIMO-2448 Add ServiceModules group in the JMX tree of the JMX portlet

Modified:
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/jmxmanager/JMXManagerHelper.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/jmxmanager/viewJMXServer.jsp

Modified: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/jmxmanager/JMXManagerHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/jmxmanager/JMXManagerHelper.java?view=diff&rev=470623&r1=470622&r2=470623
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/jmxmanager/JMXManagerHelper.java
(original)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/jmxmanager/JMXManagerHelper.java
Thu Nov  2 17:14:18 2006
@@ -48,6 +48,7 @@
     /** Used to return all MBeans */
     private static final String ALL_MBEANS = "AllMBeans";
     private static final String GBEANINFO_NAME = "GBeanInfo";
+    private static final String SERVICEMODULE_KEY = "ServiceModule";
 
     private final Kernel kernel;
 
@@ -64,13 +65,33 @@
     public Collection listByDomain(String domain) {
         Collection result = new ArrayList();
         if ((domain == null) || (domain.trim().length() == 0)) {
-            return listByPattern(domain + ":*");
+            return result;
         }
 
-        return result;
+        return listByPattern(domain + ":*");
     }
 
     /**
+     * List MBeans containing a substring in its object name
+     */
+    public Collection listBySubstring(String substring) {
+        Collection result = new ArrayList();
+        if ((substring == null) || (substring.trim().length() == 0)) {
+            return result;
+        }
+        
+        Collection abstractNames = getAbstractNames(substring);
+        for (Iterator it = abstractNames.iterator(); it.hasNext();) {
+            AbstractName aname = (AbstractName) it.next();
+            ObjectName oname = aname.getObjectName();
+            String[] pair = { aname.toString(), oname.toString() };
+            result.add(pair);
+        }
+        
+        return result;
+    }
+    
+    /**
      * List MBeans using a pattern (ObjectName)
      */
     public Collection listByPattern(String pattern) {
@@ -79,22 +100,12 @@
             return result;
         }
 
-        // Create Map (Key = ObjectName, Value = AbstractName)
-        AbstractNameQuery query = new AbstractNameQuery(null,
-                Collections.EMPTY_MAP, Collections.EMPTY_SET);
-        Set allBeans = kernel.listGBeans(query);
-        Map abstractNames = new HashMap();
-        for (Iterator it = allBeans.iterator(); it.hasNext();) {
-            AbstractName abstractName = (AbstractName) it.next();
-            ObjectName objectName = abstractName.getObjectName();
-            abstractNames.put(objectName, abstractName);
-        }
-
         try {
             // TODO: Use AbstractNameQuery
             // Uses Object names for query pattern to support
             // domain searches. Can't find a way to do it using
             // AbstractNameQuery.
+            Map abstractNames = getAbstractNames();
             ObjectName onamePattern = new ObjectName(pattern);
             Set beans = kernel.listGBeans(onamePattern);
             for (Iterator it = beans.iterator(); it.hasNext();) {
@@ -141,6 +152,62 @@
     }
 
     /**
+     * Return all service modules
+     */
+    public Collection getServiceModules() {
+        Map svcModules = new TreeMap();
+        Collection svcModuleMBeans = getAbstractNames(SERVICEMODULE_KEY + '=');
+        for (Iterator it = svcModuleMBeans.iterator(); it.hasNext();) {
+            AbstractName aname = (AbstractName) it.next();
+            String svcModule = aname.getNameProperty(SERVICEMODULE_KEY);
+            if (!svcModules.containsKey(svcModule)) {
+                svcModules.put(svcModule, null);
+            }
+        }
+
+        return svcModules.keySet();
+    }
+
+    /**
+     * Return abstract names containing a substring
+     */
+    private Collection getAbstractNames(String substring) {
+        Collection result = new ArrayList();
+        if ((substring == null) || (substring.trim().length() == 0)) {
+            return result;
+        }
+
+        Map abstractNames = getAbstractNames();
+        for (Iterator it = abstractNames.keySet().iterator(); it.hasNext();) {
+            ObjectName oname = (ObjectName) it.next();
+            if (oname.toString().indexOf(substring) > 0) {
+                AbstractName aname = (AbstractName) abstractNames.get(oname);
+                result.add(aname);
+            }
+        }
+        
+        return result;
+    }
+
+    /**
+     * Return all abstract names as a map
+     */
+    private Map getAbstractNames() {
+        Map abstractNames = new HashMap();
+        // Create Map (Key = ObjectName, Value = AbstractName)
+        AbstractNameQuery query = new AbstractNameQuery(null,
+                Collections.EMPTY_MAP, Collections.EMPTY_SET);
+        Set allBeans = kernel.listGBeans(query);
+        for (Iterator it = allBeans.iterator(); it.hasNext();) {
+            AbstractName abstractName = (AbstractName) it.next();
+            ObjectName objectName = abstractName.getObjectName();
+            abstractNames.put(objectName, abstractName);
+        }
+
+        return abstractNames;
+    }
+
+    /**
      * Return MBean attributes
      */
     public Collection getAttributes(String abstractName) {
@@ -382,14 +449,4 @@
         return result;
     }
 
-    /**
-     * For testing use...
-     */
-    public static void main(String[] args) throws Exception {
-        JMXManagerHelper helper = new JMXManagerHelper();
-        Collection c = helper.listByJ2EEType("WebModule");
-        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
-        System.out.println(c);
-        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
-    }
 }



Mime
View raw message