1 22 package org.jboss.console.plugins; 23 24 import javax.management.ObjectInstance ; 25 import javax.management.ObjectName ; 26 27 import org.jboss.console.manager.interfaces.ManageableResource; 28 import org.jboss.console.manager.interfaces.ResourceTreeNode; 29 import org.jboss.console.manager.interfaces.TreeNode; 30 import org.jboss.console.manager.interfaces.impl.MBeanResource; 31 import org.jboss.console.manager.interfaces.impl.SimpleTreeNode; 32 import org.jboss.console.plugins.helpers.AbstractPluginWrapper; 33 34 38 public class JMSLister extends AbstractPluginWrapper 39 { 40 private static final long serialVersionUID = -2428954274429502892L; 41 42 protected final static String JMX_JSR77_DOMAIN = "jboss.management.local"; 43 44 public JMSLister() 45 { 46 super(); 47 } 48 49 protected TreeNode getTreeForResource(String profile, ManageableResource resource) 50 { 51 try 52 { 53 ObjectName objName = ((MBeanResource) resource).getObjectName(); 54 SimpleTreeNode node = createTreeNode(objName.getKeyProperty("name"), "", "images/spirale.gif", null, null, createDestinations(), null ); 61 node.setMasterNode(true); 62 return node; 63 64 } 65 catch (Exception e) 66 { 67 e.printStackTrace(); 68 System.out.println(checker); 69 return null; 70 71 } 72 } 73 74 private TreeNode[] createDestinations() throws Exception 75 { 76 TreeNode[] destinations = new TreeNode[2]; 77 78 destinations[0] = createTreeNode("Queues", "", "images/spirale.gif", null, null, null, 79 createDestinationItems("Queue")); 80 destinations[1] = createTreeNode("Topics", "", "images/spirale.gif", null, null, null, 81 createDestinationItems("Topic")); 82 83 return destinations; 84 } 85 86 91 private ResourceTreeNode[] createDestinationItems(String type) throws Exception 92 { 93 ObjectInstance [] insts = getMBeansForQuery("jboss.mq.destination:service=" + type + ",*", null); 94 ResourceTreeNode[] destinations = new ResourceTreeNode[insts.length]; 95 for (int i = 0; i < insts.length; i++) 97 { 98 ObjectName objName = insts[i].getObjectName(); 99 destinations[i] = createDestinationItem(objName); 100 } 101 return destinations; 102 } 103 104 108 private ResourceTreeNode createDestinationItem(ObjectName objName) throws Exception 109 { 110 String destinationName = objName.getKeyProperty("name"); 111 String type = objName.getKeyProperty("service"); 112 String className = this.mbeanServer.getMBeanInfo(objName).getClassName(); 113 String fileName = ""; 114 if (type.equalsIgnoreCase("Queue")) 115 { 116 fileName = "Queue.jsp"; 117 } 118 else if (type.equalsIgnoreCase("Topic")) 119 { 120 fileName = "Topic.jsp"; 121 } 122 123 ResourceTreeNode item = this.createResourceNode(destinationName, type, "images/serviceset.gif", fileName + "?ObjectName=" + encode(objName.toString()), null, null, null, objName.toString(), className); 128 return item; 129 } 130 131 } 132 | Popular Tags |