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

EJBModuleLister

public class EJBModuleLister 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: 62134 $

Revisions:

2 janv. 2003 Sacha Labourey:

  • First implementation

Fields Summary
private static final long
serialVersionUID
protected static final String
JMX_JSR77_DOMAIN
Constructors Summary
public EJBModuleLister()


    
   
      super();
   
Methods Summary
org.jboss.console.manager.interfaces.ResourceTreeNode[]createBeans(javax.management.ObjectName parent)

      // there is a bug in the current jsr77 implementation with regard to naming
      // of EJBModule that are part of EARs => I've used a workaround
      //
      ObjectInstance[] insts = getMBeansForQuery(JMX_JSR77_DOMAIN + ":EJBModule=" + parent.getKeyProperty("name")
            + ",*", null);

      ResourceTreeNode[] ejbs = new ResourceTreeNode[insts.length];
      for (int i = 0; i < insts.length; i++)
      {
         ObjectName objName = insts[i].getObjectName();
         String type = objName.getKeyProperty("j2eeType");
         String ejbName = objName.getKeyProperty("name");

         String containerName = createContainerName(objName);

         if (containerName == null)
            continue;

         containerName = encode(containerName);
         String containerUrl = "/jmx-console/HtmlAdaptor?action=inspectMBean&name=" + containerName;

         TreeNodeMenuEntry[] menus = new TreeNodeMenuEntry[]
         {new SimpleTreeNodeMenuEntryImpl("View container in other window", new HttpLinkTreeAction(containerUrl,
               "_blank"))};

         String j2eeType = objName.getKeyProperty("j2eeType");
         String filename = "EJB.jsp";
         if (j2eeType.equalsIgnoreCase("StatelessSessionBean"))
         {
            filename = "StatelessEjb.jsp";
         }
         else if (j2eeType.equalsIgnoreCase("StatefulSessionBean"))
         {
            filename = "StatefulEjb.jsp";
         }
         else if (j2eeType.equalsIgnoreCase("EntityBean"))
         {
            filename = "EntityEjb.jsp";
         }
         else if (j2eeType.equalsIgnoreCase("MessageDrivenBean"))
         {
            filename = "MdbEjb.jsp";
         }

         ejbs[i] = createResourceNode(ejbName, // name
               type, // description
               "images/bean.gif", // Icon URL
               filename + "?ObjectName=" + encode(objName.toString()) + "&ContainerObjectName=" + containerName, // Default URL
               menus, null, // sub nodes
               null, // Sub-Resources                  
               objName.toString(), insts[i].getClassName());

      }

      return ejbs;
   
protected java.lang.StringcreateContainerName(javax.management.ObjectName objName)

      String jndiName = (String) mbeanServer.getAttribute(objName, "JndiName");
      String localJndiName = (String) mbeanServer.getAttribute(objName, "LocalJndiName");

      String containerUrl = null;

      String defaultContainerUrl = "jboss.j2ee:service=EJB,jndiName=" + jndiName;
      ObjectName defaultObjectName = new ObjectName(defaultContainerUrl);
      String localContainerUrl = "jboss.j2ee:service=EJB,jndiName=" + localJndiName;
      ObjectName localObjectName = new ObjectName(localContainerUrl);

      if (mbeanServer.isRegistered(defaultObjectName))
      {
         log.debug("Found container with default JNDI name URL for - " + objName.toString());
         containerUrl = defaultContainerUrl;
      }
      else if (mbeanServer.isRegistered(localObjectName))
      {
         log.debug("Found container with local JNDI name URL for - " + objName.toString());
         containerUrl = localContainerUrl;
      }
      else
      {
         log.warn("Unable to find container for - " + objName.toString());
      }

      return containerUrl;
   
protected org.jboss.console.manager.interfaces.TreeNodegetTreeForResource(java.lang.String profile, org.jboss.console.manager.interfaces.ManageableResource resource)

      try
      {
         ObjectName objName = ((MBeanResource) resource).getObjectName();

         return createTreeNode(objName.getKeyProperty("name"), // name
               "", // description
               "images/beans.gif", // Icon URL
               "EJBModule.jsp?ObjectName=" + encode(objName.toString()), // Default URL
               null, null, // sub nodes
               createBeans(objName) // Sub-Resources                  
         ).setMasterNode(true);

      }
      catch (Exception e)
      {
         e.printStackTrace();
         System.out.println(checker);
         return null;

      }