Source Code Cross Referenced for MonitorLister.java in  » EJB-Server-JBoss-4.2.1 » console » org » jboss » console » plugins » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server JBoss 4.2.1 » console » org.jboss.console.plugins 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source.
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004:         * as indicated by the @author tags. See the copyright.txt file in the
005:         * distribution for a full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package org.jboss.console.plugins;
023:
024:        import java.util.ArrayList;
025:        import java.util.Iterator;
026:        import java.util.Set;
027:
028:        import javax.management.MBeanServer;
029:        import javax.management.ObjectName;
030:
031:        import org.jboss.console.manager.interfaces.ManageableResource;
032:        import org.jboss.console.manager.interfaces.TreeNode;
033:        import org.jboss.console.plugins.helpers.AbstractPluginWrapper;
034:        import org.jboss.monitor.services.ActiveAlarmTableMBean;
035:        import org.jboss.mx.util.InstanceOfQueryExp;
036:
037:        /**
038:         * As the number of MBeans is very big, we use a real Java class which is far
039:         * faster than beanshell
040:         *
041:         * @author  <a href="mailto:sacha.labourey@cogito-info.ch">Sacha Labourey</a>.
042:         * @author  <a href="mailto:dimitris@jboss.org">Dimitris Andreadis</a>.
043:         * @version $Revision: 57191 $
044:         */
045:        public class MonitorLister extends AbstractPluginWrapper {
046:            /** @since 4.0.1 */
047:            private static final long serialVersionUID = 1625760520837838058L;
048:
049:            public MonitorLister() {
050:                super ();
051:            }
052:
053:            private TreeNode[] createMonitorSubNodes() throws Exception {
054:                MBeanServer mbeanServer = getMBeanServer();
055:                InstanceOfQueryExp queryExp = null;
056:                queryExp = new InstanceOfQueryExp(
057:                        "org.jboss.monitor.JBossMonitorMBean");
058:                Set monitors = mbeanServer.queryNames(null, queryExp);
059:                Iterator mbeans = monitors.iterator();
060:                ;
061:
062:                TreeNode[] result = null;
063:
064:                ArrayList monitorNodes = new ArrayList();
065:
066:                String emptySig[] = {};
067:                Object emptyArgs[] = {};
068:                while (mbeans.hasNext()) {
069:                    ObjectName mbean = (ObjectName) mbeans.next();
070:                    String monitorName = (String) mbeanServer.getAttribute(
071:                            mbean, "MonitorName");
072:                    boolean alerted = ((Boolean) mbeanServer.invoke(mbean,
073:                            "alerted", emptyArgs, emptySig)).booleanValue();
074:                    //String image = alerted ? "images/red_bullet.gif" : "images/green_bullet.gif";
075:                    String image = "images/service.gif";
076:                    Object[] args = { "monitors", monitorName, "-service.xml" };
077:                    String[] signature = { "java.lang.String",
078:                            "java.lang.String", "java.lang.String" };
079:                    Object rtn = mbeanServer.invoke(new ObjectName(
080:                            "jboss.admin:service=DeploymentFileRepository"),
081:                            "isStored", args, signature);
082:                    boolean persisted = ((Boolean) rtn).booleanValue();
083:                    String url = "";
084:                    if (persisted) {
085:                        url = "manageThresholdMonitor.jsp?monitorObjectName="
086:                                + encode(mbean.toString());
087:                    } else {
088:                        url = "/jmx-console/HtmlAdaptor?action=inspectMBean&name="
089:                                + encode(mbean.toString());
090:                    }
091:                    monitorNodes.add(createTreeNode(monitorName, // name
092:                            "Alert Monitor " + monitorName, // description
093:                            image, // Icon URL
094:                            url, // Default URL
095:                            null, // menu
096:                            null, // sub nodes
097:                            null // Sub-Resources                  
098:                            ));
099:
100:                }
101:
102:                if (monitorNodes.size() == 0) {
103:                    result = null;
104:                } else {
105:                    result = (TreeNode[]) monitorNodes
106:                            .toArray(new TreeNode[monitorNodes.size()]);
107:                }
108:
109:                return result;
110:            }
111:
112:            private TreeNode[] createSnapshotSubNodes() throws Exception {
113:                MBeanServer mbeanServer = getMBeanServer();
114:                InstanceOfQueryExp queryExp = null;
115:                queryExp = new InstanceOfQueryExp(
116:                        "org.jboss.monitor.SnapshotRecordingMonitorMBean");
117:                Set monitors = mbeanServer.queryNames(null, queryExp);
118:                Iterator mbeans = monitors.iterator();
119:                ;
120:
121:                TreeNode[] result = null;
122:
123:                ArrayList monitorNodes = new ArrayList();
124:
125:                while (mbeans.hasNext()) {
126:                    ObjectName mbean = (ObjectName) mbeans.next();
127:                    String monitorName = (String) mbeanServer.getAttribute(
128:                            mbean, "MonitorName");
129:                    String url = "manageSnapshot.jsp?monitorObjectName="
130:                            + encode(mbean.toString());
131:                    String image = "images/service.gif";
132:                    monitorNodes.add(createTreeNode(monitorName, // name
133:                            "Snapshot " + monitorName, // description
134:                            image, // Icon URL
135:                            url, // Default URL
136:                            null, // menu
137:                            null, // sub nodes
138:                            null // Sub-Resources
139:                            ));
140:
141:                }
142:
143:                if (monitorNodes.size() == 0) {
144:                    result = null;
145:                } else {
146:                    result = (TreeNode[]) monitorNodes
147:                            .toArray(new TreeNode[monitorNodes.size()]);
148:                }
149:
150:                return result;
151:            }
152:
153:            private TreeNode[] createWebSubNodes() throws Exception {
154:                TreeNode[] webSubNodes = new TreeNode[2];
155:
156:                webSubNodes[0] = createTreeNode("Connector scoreboard", // name
157:                        "JBossWeb Connectors status scoreboard", // description
158:                        "images/smallnet.gif", // Icon URL
159:                        "status", // Default URL
160:                        null, null, // sub nodes
161:                        null // Sub-Resources
162:                );
163:                webSubNodes[1] = createTreeNode("Full status", // name
164:                        "JBossWeb complete status", // description
165:                        "images/smallnet.gif", // Icon URL
166:                        "status?full=true", // Default URL
167:                        null, null, // sub nodes
168:                        null // Sub-Resources
169:                );
170:
171:                return webSubNodes;
172:            }
173:
174:            protected TreeNode getTreeForResource(String profile,
175:                    ManageableResource resource) {
176:                try {
177:                    ArrayList subNodeList = new ArrayList();
178:
179:                    if (isActiveAlarmTablePresent()) {
180:                        subNodeList.add(createTreeNode("Alarm Table", // name
181:                                "Alarm Table", // description
182:                                "images/smallnet.gif", // icon URL
183:                                "listActiveAlarmTable.jsp", // default URL
184:                                null, null, // sub-nodes
185:                                null // sub-resources
186:                                ));
187:                    }
188:
189:                    subNodeList.add(createTreeNode("Monitor Alerts", // name
190:                            "Monitor Alerts", // description
191:                            "images/smallnet.gif", // Icon URL
192:                            "listMonitors.jsp", // Default URL
193:                            null, createMonitorSubNodes(), // sub nodes
194:                            null // Sub-Resources
195:                            ));
196:
197:                    subNodeList.add(createTreeNode("Snapshots", // name
198:                            "Snapshot Monitors", // description
199:                            "images/smallnet.gif", // Icon URL
200:                            null, // Default URL
201:                            null, createSnapshotSubNodes(), // sub nodes
202:                            null // Sub-Resources
203:                            ));
204:
205:                    subNodeList.add(createTreeNode("Web Status", // name
206:                            "JBossWeb Connectors status", // description
207:                            "images/smallnet.gif", // Icon URL
208:                            null, // Default URL
209:                            null, createWebSubNodes(), // sub nodes
210:                            null // Sub-Resources
211:                            ));
212:
213:                    // convert ArrayList to TreeNode[]
214:                    TreeNode[] subnodes = (TreeNode[]) subNodeList
215:                            .toArray(new TreeNode[subNodeList.size()]);
216:
217:                    return createTreeNode("Monitoring", // name
218:                            "Monitoring", // description
219:                            "images/smallnet.gif", // Icon URL
220:                            null, // Default URL
221:                            null, subnodes, // sub nodes
222:                            null // Sub-Resources
223:                    );
224:                } catch (Exception e) {
225:                    e.printStackTrace();
226:                    return null;
227:                }
228:            }
229:
230:            private boolean isActiveAlarmTablePresent() {
231:                MBeanServer server = getMBeanServer();
232:                return server.isRegistered(ActiveAlarmTableMBean.OBJECT_NAME);
233:            }
234:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.