1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.hack23.cia.web.impl.ui.page.admin;
20
21 import java.util.Arrays;
22 import java.util.Set;
23
24 import javax.management.MBeanAttributeInfo;
25 import javax.management.MBeanInfo;
26 import javax.management.MBeanOperationInfo;
27 import javax.management.MBeanServer;
28 import javax.management.ObjectName;
29
30 import org.springframework.jmx.support.JmxUtils;
31
32 import com.hack23.cia.web.impl.ui.page.common.AbstractPanel;
33 import com.vaadin.data.Item;
34 import com.vaadin.ui.Tree;
35 import com.vaadin.ui.VerticalLayout;
36
37 /***
38 * The Class JmxPanel.
39 */
40 public class JmxPanel extends AbstractPanel {
41
42 /*** The content. */
43 private VerticalLayout content = null;
44
45 /*** The Constant serialVersionUID. */
46 private static final long serialVersionUID = 1L;
47
48 /***
49 * Instantiates a new jmx panel.
50 */
51 public JmxPanel() {
52 super();
53 content =new VerticalLayout();
54 setContent(content);
55 content.setHeight(null);
56 content.setWidth("100%");
57
58 content.setSpacing(true);
59 content.setMargin(true);
60
61
62 String[] domains;
63 try {
64 MBeanServer mBeanServer = JmxUtils.locateMBeanServer();
65
66
67 domains = mBeanServer.getDomains();
68 Arrays.sort(domains);
69
70 final Tree tree = new Tree("Domains");
71
72 for (int i=0; i<domains.length; i++) {
73 final String domain = (domains[i]);
74 final Item domainItem = tree.addItem(domain);
75 Set<ObjectName> queryNames = mBeanServer.queryNames(new ObjectName(domain + ":*"), null);
76
77 for (final ObjectName objectName: queryNames)
78 {
79 MBeanInfo mBeanInfo = mBeanServer.getMBeanInfo(objectName);
80
81 final String objectCaption = mBeanInfo.getClassName();
82
83 final Item objectNameItem = tree.addItem(objectCaption);
84 tree.setParent(objectCaption, domain);
85
86
87 final String attributeHeaderCaption = objectCaption +".Attributes";
88 final Item attributeHeaderItem = tree.addItem(attributeHeaderCaption);
89 tree.setParent(attributeHeaderCaption,objectCaption);
90
91 MBeanAttributeInfo[] attributes = mBeanInfo.getAttributes();
92 for (MBeanAttributeInfo mBeanAttributeInfo: attributes) {
93 String attributeCaption = objectCaption + "." + mBeanAttributeInfo.getDescription();
94 final Item attributeItem = tree.addItem(attributeCaption);
95 tree.setParent(attributeCaption, objectCaption);
96 }
97
98
99 final String opHeaderCaption = objectCaption +".Operations";
100 final Item opHeaderItem = tree.addItem(opHeaderCaption);
101 tree.setParent(opHeaderCaption,objectCaption);
102
103 MBeanOperationInfo[] operations = mBeanInfo.getOperations();
104
105 for (MBeanOperationInfo mBeanOperationInfo: operations) {
106 String opCaption = objectCaption + "." + mBeanOperationInfo.getDescription();
107 final Item opItem = tree.addItem(opCaption);
108 tree.setParent(opCaption, opHeaderCaption);
109 }
110
111 }
112
113 }
114
115 content.addComponent(tree);
116 tree.setSizeFull();
117 } catch (final Exception e) {
118 e.printStackTrace();
119 }
120
121 setSizeFull();
122
123 setCaption(translateFromEnglish("Jmx Panel"));
124 }
125
126
127 }