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

JSR77Lister

public class JSR77Lister 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
author
Sacha Labourey
author
Dimitris Andreadis
version
$Revision: 57191 $

Fields Summary
private static final long
serialVersionUID
public static final String[]
DEFAULT_SUFFIX_ORDER
Constructors Summary
public JSR77Lister()
Default CTOR


         
    
   
      super();
   
Methods Summary
org.jboss.console.manager.interfaces.ResourceTreeNode[]createDeployedObjects(java.lang.String[] resources)

      ArrayList deployed = new ArrayList ();
      for (int i = 0; i < resources.length; i++)
      {
         ObjectName objectName = new ObjectName(resources[i]);
         //if (resources[i].getKeyProperty ("J2EEApplication") == null)
         {
            deployed.add(createResourceNode (
               objectName.getKeyProperty("name"), // name
               "", // description
               "images/EspressoMaker.gif", // Icon URL
               null, // "J2EEApp.jsp?ObjectName=" + encode (objName.toString ()), // Default URL
               null,
               null, // sub nodes
               null, //createEARSubModules (objName), // Sub-Resources
               resources[i].toString (),
               this.mbeanServer.getMBeanInfo (objectName).getClassName ()
            ).setVisibility (ResourceTreeNode.INVISIBLE_IF_SUBNODE_EXISTS));
         }

      }
      Collections.sort(deployed, new ListerSorter());

      return (ResourceTreeNode[])deployed.toArray(new ResourceTreeNode[deployed.size()]);
   
org.jboss.console.manager.interfaces.TreeNodecreateDomain(javax.management.ObjectName domain)

      return createTreeNode(
         domain.getKeyProperty("name"), // name
         "", // description
         "images/spirale.gif", // Icon URL
         null, //"J2EEDomain.jsp&objectName=" + encode(objName.toString()), // Default URL
         null,
         null, // sub nodes
         createServers(domain)   // Sub-Resources
      );
   
org.jboss.console.manager.interfaces.TreeNode[]createDomains()
Find the root JSR-77 domains

      // The potential list of domain starting points. According to the
      // spec we should be looking for *:j2eeType=J2EEDomain,* where
      // the value of the "name" attribute matches the domain name.
      ObjectInstance[] insts = getMBeansForQuery("*:j2eeType=J2EEDomain,*", null);
      
      // Holds the domains that are succesfully created
      ArrayList domainsCreated = new ArrayList();
      
      for (int i=0; i < insts.length; i++)
      {
         ObjectName objectName = insts[i].getObjectName();
         try
         {
            if (objectName.getDomain().equals(objectName.getKeyProperty("name")))
            {
               // value of "name" attribute matches the domain name, assume is ok
               domainsCreated.add(createDomain(objectName));
            }
         }
         catch (AttributeNotFoundException e)
         {
            // we are looking at a bad starting point
            System.err.println(e.getClass().getName() + ": " + e.getMessage()
                  + "; mbean '" + objectName + "' not a proper j2eeType=J2EEDomain");
         }
         catch (Exception e)
         {
            // show error and continue
            e.printStackTrace();
         }
      }
      // Transform the list to TreeNode[]
      TreeNode[] domains = (TreeNode[])domainsCreated.toArray(new TreeNode[domainsCreated.size()]);
      
      // Done
      return domains;
   
org.jboss.console.manager.interfaces.ResourceTreeNodecreateServer(java.lang.String serverName)


      ObjectName objectName = new ObjectName(serverName);
      J2EEServerMBean serv = (J2EEServerMBean)
         MBeanProxyExt.create(J2EEServerMBean.class, objectName, getMBeanServer ());

      String[] deployedON = serv.getdeployedObjects();
      ResourceTreeNode[] subResArray = createDeployedObjects (deployedON);

      return createResourceNode (
         serv.getserverVendor () + " - " + serv.getserverVersion (), // name
         objectName.getKeyProperty ("name"), // description
         "images/database.gif", // Icon URL
         null, //"J2EEDomain.jsp?objectName=" + encode(objName.toString()), // Default URL
         null,
         new TreeNode[] {createSubResources (serv.getresources())}, // sub nodes
         subResArray, // Sub-Resources
         serverName.toString (),
         org.jboss.management.j2ee.J2EEServer.class.getName ()
      );

   
org.jboss.console.manager.interfaces.ResourceTreeNode[]createServers(javax.management.ObjectName domain)

      // will throw an exception if there is no such attribute
      String[] serversObjectNames = (String[])getMBeanServer().getAttribute(domain, "servers");
      
      ArrayList servers = new ArrayList();
      for (int i = 0; i < serversObjectNames.length; i++)
      {
         servers.add(createServer(serversObjectNames[i]));
      }

      return (ResourceTreeNode[])servers.toArray(new ResourceTreeNode[servers.size()]);
   
org.jboss.console.manager.interfaces.TreeNodecreateSubResources(java.lang.String[] resources)

      ResourceTreeNode[] deployed = new ResourceTreeNode[resources.length];
      for (int i = 0; i < resources.length; i++)
      {
         ObjectName objectName = new ObjectName(resources[i]);
         deployed[i] = createResourceNode (
            objectName.getKeyProperty ("name"), // name
            "J2EE Resource", // description
            null, //"images/EspressoMaker.gif", // Icon URL
            null, // "J2EEApp.jsp?ObjectName=" + encode (objName.toString ()), // Default URL
            null,
            null, // sub nodes
            null, //createEARSubModules (objName), // Sub-Resources
            resources[i].toString (),
            this.mbeanServer.getMBeanInfo (objectName).getClassName ()
         ).setVisibility (ResourceTreeNode.INVISIBLE_IF_SUBNODE_EXISTS);
      }

      return createTreeNode (
         "J2EE Resources", // name
         "J2EE Resources", // description
         "images/spirale.gif", // Icon URL
         null, //"J2EEDomain.jsp&objectName=" + encode(objName.toString()), // Default URL
         null,
         null, // sub nodes
         deployed   // Sub-Resources
      );
   
protected org.jboss.console.manager.interfaces.TreeNodegetTreeForResource(java.lang.String profile, org.jboss.console.manager.interfaces.ManageableResource resource)

      try
      {
         return createTreeNode (
               "J2EE Domains",  // name
               "Display JSR-77 Managed Objects", // description
               "images/elements32.gif", // Icon URL
               null, // Default URL
               null,
               createDomains (), // sub nodes
               null   // Sub-Resources                  
            );            
      }
      catch (Exception e)
      {
         e.printStackTrace ();
         return null;
      }