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

MonitorLister

public class MonitorLister 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
Constructors Summary
public MonitorLister()


       super(); 
Methods Summary
private org.jboss.console.manager.interfaces.TreeNode[]createMonitorSubNodes()

      MBeanServer mbeanServer = getMBeanServer();
      InstanceOfQueryExp queryExp = null;
      queryExp = new InstanceOfQueryExp("org.jboss.monitor.JBossMonitorMBean");
      Set monitors = mbeanServer.queryNames(null, queryExp);
      Iterator mbeans = monitors.iterator();;
      
      TreeNode[] result = null;
      
      ArrayList monitorNodes = new ArrayList ();

      String emptySig[] = {};
      Object emptyArgs[] = {};
      while( mbeans.hasNext() )
      {
         ObjectName mbean = (ObjectName)mbeans.next();
         String monitorName = (String)mbeanServer.getAttribute(mbean, "MonitorName");
         boolean alerted = ((Boolean)mbeanServer.invoke(mbean, "alerted", emptyArgs, emptySig)).booleanValue();
         //String image = alerted ? "images/red_bullet.gif" : "images/green_bullet.gif";
         String image = "images/service.gif";
         Object[] args = {"monitors", monitorName, "-service.xml"};
         String[] signature = {"java.lang.String", "java.lang.String", "java.lang.String"};
         Object rtn = mbeanServer.invoke(new ObjectName("jboss.admin:service=DeploymentFileRepository"), "isStored", args, signature);
         boolean persisted = ((Boolean)rtn).booleanValue();
         String url = "";
         if (persisted)
         {
            url = "manageThresholdMonitor.jsp?monitorObjectName=" + encode(mbean.toString());
         }
         else
         {
            url = "/jmx-console/HtmlAdaptor?action=inspectMBean&name=" +encode(mbean.toString());
         }
         monitorNodes.add(createTreeNode (
               monitorName, // name
               "Alert Monitor " + monitorName, // description
               image, // Icon URL
               url, // Default URL
               null, // menu
               null, // sub nodes
               null   // Sub-Resources                  
            )
         );       
         
      }
      
      if (monitorNodes.size() == 0)
      {
         result = null;
      }
      else
      {
         result = (TreeNode[]) monitorNodes.toArray(new TreeNode[monitorNodes.size()]);
      }
      
      return result;                                                  
   
private org.jboss.console.manager.interfaces.TreeNode[]createSnapshotSubNodes()

      MBeanServer mbeanServer = getMBeanServer();
      InstanceOfQueryExp queryExp = null;
      queryExp = new InstanceOfQueryExp("org.jboss.monitor.SnapshotRecordingMonitorMBean");
      Set monitors = mbeanServer.queryNames(null, queryExp);
      Iterator mbeans = monitors.iterator();;

      TreeNode[] result = null;

      ArrayList monitorNodes = new ArrayList ();

      while( mbeans.hasNext() )
      {
         ObjectName mbean = (ObjectName)mbeans.next();
         String monitorName = (String)mbeanServer.getAttribute(mbean, "MonitorName");
         String url = "manageSnapshot.jsp?monitorObjectName=" + encode(mbean.toString());
         String image = "images/service.gif";
         monitorNodes.add(createTreeNode (
               monitorName, // name
               "Snapshot " + monitorName, // description
               image, // Icon URL
               url, // Default URL
               null, // menu
               null, // sub nodes
               null   // Sub-Resources
            )
         );

      }

      if (monitorNodes.size() == 0)
      {
         result = null;
      }
      else
      {
         result = (TreeNode[]) monitorNodes.toArray(new TreeNode[monitorNodes.size()]);
      }

      return result;
   
private org.jboss.console.manager.interfaces.TreeNode[]createWebSubNodes()

      TreeNode[] webSubNodes = new TreeNode[2];
      
      webSubNodes[0] = createTreeNode(
            "Connector scoreboard", // name
            "JBossWeb Connectors status scoreboard", // description
            "images/smallnet.gif", // Icon URL
            "status", // Default URL
            null,
            null, // sub nodes
            null   // Sub-Resources
         );
      webSubNodes[1] = createTreeNode(
            "Full status", // name
            "JBossWeb complete status", // description
            "images/smallnet.gif", // Icon URL
            "status?full=true", // Default URL
            null,
            null, // sub nodes
            null   // Sub-Resources
         );
     
      return webSubNodes;
   
protected org.jboss.console.manager.interfaces.TreeNodegetTreeForResource(java.lang.String profile, org.jboss.console.manager.interfaces.ManageableResource resource)

      try
      {
         ArrayList subNodeList = new ArrayList();
         
         if (isActiveAlarmTablePresent())
         {
            subNodeList.add(createTreeNode(
                  "Alarm Table", // name
                  "Alarm Table", // description
                  "images/smallnet.gif", // icon URL
                  "listActiveAlarmTable.jsp", // default URL
                  null,
                  null, // sub-nodes
                  null // sub-resources
                  ));
         }
         
         subNodeList.add(createTreeNode(
               "Monitor Alerts", // name
               "Monitor Alerts", // description
               "images/smallnet.gif", // Icon URL
               "listMonitors.jsp", // Default URL
               null,
               createMonitorSubNodes(), // sub nodes
               null   // Sub-Resources
            ));
         
         subNodeList.add(createTreeNode(
               "Snapshots", // name
               "Snapshot Monitors", // description
               "images/smallnet.gif", // Icon URL
               null, // Default URL
               null,
               createSnapshotSubNodes(), // sub nodes
               null   // Sub-Resources
            ));
         
         subNodeList.add(createTreeNode(
               "Web Status", // name
               "JBossWeb Connectors status", // description
               "images/smallnet.gif", // Icon URL
               null, // Default URL
               null,
               createWebSubNodes(), // sub nodes
               null   // Sub-Resources
            )); 
         
         // convert ArrayList to TreeNode[]
         TreeNode[] subnodes = (TreeNode[]) subNodeList.toArray(new TreeNode[subNodeList.size()]);
         
         return createTreeNode (
               "Monitoring", // name
               "Monitoring", // description
               "images/smallnet.gif", // Icon URL
               null, // Default URL
               null,
               subnodes, // sub nodes
               null   // Sub-Resources
            );
      }
      catch (Exception e)
      {
         e.printStackTrace ();
         return null;
      }
   
private booleanisActiveAlarmTablePresent()

      MBeanServer server = getMBeanServer();
      return server.isRegistered(ActiveAlarmTableMBean.OBJECT_NAME);