1 22 package org.jboss.console.plugins; 23 24 import org.jboss.console.manager.interfaces.ManageableResource; 25 import org.jboss.console.manager.interfaces.ResourceTreeNode; 26 import org.jboss.console.manager.interfaces.TreeNode; 27 import org.jboss.console.manager.interfaces.TreeNodeMenuEntry; 28 import org.jboss.console.manager.interfaces.impl.HttpLinkTreeAction; 29 import org.jboss.console.manager.interfaces.impl.MBeanResource; 30 import org.jboss.console.manager.interfaces.impl.SimpleTreeNodeMenuEntryImpl; 31 import org.jboss.console.plugins.helpers.AbstractPluginWrapper; 32 33 import javax.management.ObjectInstance ; 34 import javax.management.ObjectName ; 35 51 public class EJBModuleLister 52 extends AbstractPluginWrapper 53 { 54 55 protected final static String JMX_JSR77_DOMAIN = "jboss.management.local"; 56 57 public EJBModuleLister () { super(); } 58 59 ResourceTreeNode[] createBeans (ObjectName parent) throws Exception 60 { 61 ObjectInstance [] insts = getMBeansForQuery(JMX_JSR77_DOMAIN + 65 ":EJBModule="+parent.getKeyProperty("name")+",*", null); 66 67 ResourceTreeNode[] ejbs = new ResourceTreeNode[insts.length]; 68 for (int i=0; i<insts.length; i++) 69 { 70 ObjectName objName = insts[i].getObjectName(); 71 String type = objName.getKeyProperty("j2eeType"); 72 73 String ejbName = objName.getKeyProperty("name"); 74 String containerUrl = "jboss.j2ee:service=EJB,jndiName=" + ejbName; 75 containerUrl = java.net.URLEncoder.encode(containerUrl); 76 containerUrl = "/jmx-console/HtmlAdaptor?action=inspectMBean&name=" + containerUrl; 77 78 TreeNodeMenuEntry[] menus = new TreeNodeMenuEntry[] 79 { 80 new SimpleTreeNodeMenuEntryImpl ("View container in other window", 81 new HttpLinkTreeAction (containerUrl, "_blank") 82 ) 83 }; 84 85 String j2eeType = objName.getKeyProperty ("j2eeType"); 86 String filename = "EJB.jsp"; 87 if (j2eeType.equalsIgnoreCase ("StatelessSessionBean")) 88 { 89 filename = "StatelessEjb.jsp"; 90 } 91 else if (j2eeType.equalsIgnoreCase ("StatefulSessionBean")) 92 { 93 filename = "StatefulEjb.jsp"; 94 } 95 else if (j2eeType.equalsIgnoreCase ("EntityBean")) 96 { 97 filename = "EntityEjb.jsp"; 98 } 99 else if (j2eeType.equalsIgnoreCase ("MessageDrivenBean")) 100 { 101 filename = "MdbEjb.jsp"; 102 } 103 104 ejbs[i] = createResourceNode( 105 ejbName, type, "images/bean.gif", filename+"?ObjectName=" + encode(objName.toString()), menus, 110 null, null, objName.toString(), 113 insts[i].getClassName() 114 ); 115 116 } 117 118 return ejbs; 119 } 120 121 protected TreeNode getTreeForResource(String profile, ManageableResource resource) 122 { 123 try 124 { 125 ObjectName objName = ((MBeanResource)resource).getObjectName(); 126 127 return createTreeNode 128 ( 129 objName.getKeyProperty("name"), "", "images/beans.gif", "EJBModule.jsp?ObjectName=" + encode(objName.toString()), null, 134 null, createBeans (objName) ).setMasterNode(true); 137 138 } 139 catch (Exception e) 140 { 141 e.printStackTrace (); 142 System.out.println (checker); 143 return null; 144 145 } 146 } 147 148 } 149 | Popular Tags |