FileDocCategorySizeDatePackage
MBeansLister.javaAPI DocJBoss 4.2.18049Fri Jul 13 21:02:14 BST 2007org.jboss.console.plugins

MBeansLister

public class MBeansLister extends org.jboss.console.plugins.helpers.AbstractPluginWrapper
As the number of MBeans is very big, we use a real Java class which is far faster than beanshell
see
author
Sacha Labourey.
version
$Revision: 57191 $

Revisions:

2 janv. 2003 Sacha Labourey:

  • First implementation

Fields Summary
private static HashSet
graphableClasses
Constructors Summary
public MBeansLister()


   
   
      graphableClasses.add("java.lang.Integer");
      graphableClasses.add("java.lang.Short");
      graphableClasses.add("java.lang.Double");
      graphableClasses.add("java.lang.Float");
      graphableClasses.add("java.lang.Long");
      graphableClasses.add("int");
      graphableClasses.add("short");
      graphableClasses.add("double");
      graphableClasses.add("float");
      graphableClasses.add("long");
    super(); 
Methods Summary
org.jboss.console.manager.interfaces.TreeNodecreateJmxAttributeSubResource(javax.management.MBeanAttributeInfo attr, javax.management.ObjectName mbeanName)

      TreeNodeMenuEntry[] entries = null;
      if (graphableClasses.contains(attr.getType()))
      {
         SimpleTreeNodeMenuEntryImpl entry = new SimpleTreeNodeMenuEntryImpl("graph", new GraphMBeanAttributeAction(mbeanName, attr.getName()));
         SimpleTreeNodeMenuEntryImpl entry2 = new SimpleTreeNodeMenuEntryImpl("create monitor", new HttpLinkTreeAction(
                 "/web-console/createThresholdMonitor.jsp?attribute=" + attr.getName() + "&objectName=" + encode(mbeanName.toString())));
         SimpleTreeNodeMenuEntryImpl entry3 = new SimpleTreeNodeMenuEntryImpl("create snapshot", new HttpLinkTreeAction(
                 "/web-console/createSnapshot.jsp?attribute=" + attr.getName() + "&objectName=" + encode(mbeanName.toString())));
         entries = new TreeNodeMenuEntry[3];
         entries[0] = entry;
         entries[1] = entry2;
         entries[2] = entry3;
      }
      else if (attr.getType().equals("String") || attr.getType().equals("java.lang.String"))
      {
         SimpleTreeNodeMenuEntryImpl entry = new SimpleTreeNodeMenuEntryImpl("create monitor", new HttpLinkTreeAction(
                 "/web-console/createStringThresholdMonitor.jsp?attribute=" + attr.getName() + "&objectName=" + encode(mbeanName.toString())));
         entries = new TreeNodeMenuEntry[1];
         entries[0] = entry;
      }

      return createTreeNode(
              attr.getName(),
              attr.getDescription(),
              "images/container.gif",
              "/jmx-console/HtmlAdaptor?action=inspectMBean&name=" + encode("" + mbeanName), // Default URL
              entries,
              null,
              null
              //name,
              //data.getClassName() TOO HEAVY TO GENERATE RESOURCE LOOKUP FOR EACH MBEAN!
           );
   
org.jboss.console.manager.interfaces.TreeNode[]createJmxDomainsSubNodes()

      Iterator mbeans = Server.getDomainData(null);
      
      TreeNode[] result = null;
      
      ArrayList domains = new ArrayList ();            
            
      while( mbeans.hasNext() )
      {
         DomainData domainData = (DomainData) mbeans.next();         
         String domainName = domainData.getDomainName();
         MBeanData[] data = domainData.getData();                                    
         TreeNode[] subResources = new TreeNode[data.length];
         
         for(int d = 0; d < data.length; d ++)
         {
            subResources[d] = createJmxMBeanSubResources (data[d]);
         }

         TreeNodeMenuEntry[] menu = createMenus (new String[] 
            {
               "Number of MBeans: " + data.length, null,
            }
         );
         
         domains.add(createTreeNode (
               domainName, // name
               "MBeans for domain " + domainName, // description
               "images/serviceset.gif", // Icon URL
               null, // Default URL
               menu, // menu
               subResources, // sub nodes
               null   // Sub-Resources                  
            )
         );       
         
      }
      
      if (domains.size() == 0)
      {
         result = null;
      }
      else
      {
         result = (TreeNode[]) domains.toArray(new TreeNode[domains.size()]);
      }
      
      return result;                                                  
   
org.jboss.console.manager.interfaces.TreeNodecreateJmxMBeanSubResources(org.jboss.console.plugins.helpers.jmx.MBeanData data)

      String name = "" + data.getObjectName();
      String displayName = data.getName ();
            
      if (displayName == null)
      {
         // Get ride of the domain name because it is already is the header
         int index = name.indexOf( ":" );
         displayName = ( index >= 0 ) ? name.substring( index + 1 ) : name;
      }

      MBeanAttributeInfo[] attributes = data.getMetaData().getAttributes();
      TreeNode[] attrNodes = new TreeNode[attributes.length];
      for (int i = 0; i < attributes.length; i++)
      {
         attrNodes[i] = createJmxAttributeSubResource(attributes[i], data.getObjectName());
      }

      return createTreeNode (
            displayName, // name
            name, // description
            "images/server.gif", // Icon URL
            "/jmx-console/HtmlAdaptor?action=inspectMBean&name=" + encode(name), // Default URL
            null,
            attrNodes,
            null
            //name,
            //data.getClassName() TOO HEAVY TO GENERATE RESOURCE LOOKUP FOR EACH MBEAN!
         );
   
protected org.jboss.console.manager.interfaces.TreeNodegetTreeForResource(java.lang.String profile, org.jboss.console.manager.interfaces.ManageableResource resource)

      try
      {
         return createTreeNode (
               "JMX MBeans", // name
               "Display all JMX MBeans", // description
               "images/flash.gif", // Icon URL
               "/jmx-console/HtmlAdaptor?action=displayMBeans", // Default URL
               null,
               createJmxDomainsSubNodes (), // sub nodes
               null   // Sub-Resources                  
            );            
      }
      catch (Exception e)
      {
         e.printStackTrace ();
         return null;
      }