Source Code Cross Referenced for AlarmNotification.java in  » EJB-Server-JBoss-4.2.1 » varia » org » jboss » monitor » alarm » 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 » varia » org.jboss.monitor.alarm 
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.monitor.alarm;
023:
024:        import javax.management.Notification;
025:        import javax.management.ObjectName;
026:
027:        /**
028:         * AlarmNotification
029:         *
030:         * @author  <a href="mailto:dimitris@jboss.org">Dimitris Andreadis</a>
031:         * @version $Revision: 57210 $
032:         */
033:        public class AlarmNotification extends Notification {
034:            // Private Data --------------------------------------------------
035:
036:            /** @since 4.0.4 */
037:            private static final long serialVersionUID = -7041616127511632675L;
038:
039:            /** Set when the alarm refers to some other MBean */
040:            private ObjectName target;
041:
042:            /** The alarm severity */
043:            private int severity;
044:
045:            /** The alarm state */
046:            private int alarmState;
047:
048:            // CTORS ---------------------------------------------------------
049:
050:            /**
051:             * Complete CTOR, creates an AlarmNotification object
052:             *
053:             * Note:
054:             *   STATE_CLEARED forces severity to SEVERITY_NORMAL
055:             *   STATE_CREATED/CHANGED have valid severities WARNING to UNKNOWN
056:             *   STATE_NONE has valid severities NORMAL to UNKNOWN
057:             * Also:
058:             *   Out-of-range states are mapped to STATE_NONE
059:             *   Out-of-range severities are mapped to SEVERITY_UNKNOWN
060:             */
061:            public AlarmNotification(String type, Object source,
062:                    ObjectName target, int severity, int alarmState,
063:                    long sequenceNumber, long timeStamp, String message) {
064:                super (type, source, sequenceNumber, timeStamp, message);
065:
066:                this .target = target;
067:
068:                switch (alarmState) {
069:                case Alarm.STATE_CLEARED:
070:                    this .alarmState = Alarm.STATE_CLEARED;
071:                    // forces severity=SEVERITY_NORMAL
072:                    this .severity = Alarm.SEVERITY_NORMAL;
073:                    break;
074:
075:                case Alarm.STATE_CREATED:
076:                case Alarm.STATE_CHANGED:
077:                    this .alarmState = alarmState;
078:                    // can't have SEVERITY_NORMAL!
079:                    if (severity > Alarm.SEVERITY_NORMAL
080:                            && severity <= Alarm.SEVERITY_UNKNOWN) {
081:                        this .severity = severity;
082:                    } else // handle out of range severity as SEVERITY_UNKNOWN
083:                    {
084:                        this .severity = Alarm.SEVERITY_UNKNOWN;
085:                    }
086:                    break;
087:
088:                case Alarm.STATE_NONE:
089:                default: // handle out of range alarmState as STATE_NONE
090:                    this .alarmState = Alarm.STATE_NONE;
091:                    if (severity >= Alarm.SEVERITY_NORMAL
092:                            && severity <= Alarm.SEVERITY_UNKNOWN) {
093:                        this .severity = severity;
094:                    } else // handle out of range severity as SEVERITY_UNKNOWN
095:                    {
096:                        this .severity = Alarm.SEVERITY_UNKNOWN;
097:                    }
098:                    break;
099:                }
100:            }
101:
102:            // Static --------------------------------------------------------
103:
104:            /**
105:             * Returns a key that can be used in AlarmTables (maps)
106:             */
107:            public static Object createKey(Notification n) {
108:                Object source = getEffectiveSource(n);
109:                return AlarmKey.createKey(source, n.getType());
110:            }
111:
112:            /**
113:             * Returns the effective source for the notification.
114:             * In case of a AlarmNotification with a non-null target
115:             * the target becomes the source.
116:             */
117:            public static Object getEffectiveSource(Notification n) {
118:                Object source = n.getSource();
119:                if (n instanceof  AlarmNotification) {
120:                    ObjectName target = ((AlarmNotification) n).getTarget();
121:                    if (target != null) {
122:                        source = target;
123:                    }
124:                }
125:                return source;
126:            }
127:
128:            // Accessors -----------------------------------------------------
129:
130:            /**
131:             * Gets the target MBean name, when the alarm is produced
132:             * by 'source' on behalf of the 'target', or null. 
133:             */
134:            public ObjectName getTarget() {
135:                return target;
136:            }
137:
138:            /**
139:             * Gets alarm severity
140:             */
141:            public int getSeverity() {
142:                return this .severity;
143:            }
144:
145:            /**
146:             * Gets alarm state
147:             */
148:            public int getAlarmState() {
149:                return this .alarmState;
150:            }
151:
152:            // Object stuff --------------------------------------------------
153:
154:            /**
155:             * toString()
156:             */
157:            public String toString() {
158:                StringBuffer sbuf = new StringBuffer(256);
159:
160:                sbuf.append(AlarmNotification.class.getName());
161:                sbuf.append(" [ type=").append(getType());
162:                sbuf.append(", source=").append(getSource());
163:                sbuf.append(", target=").append(target);
164:                sbuf.append(", severity=").append(
165:                        Alarm.SEVERITY_STRINGS[severity]);
166:                sbuf.append(", alarmState=").append(
167:                        Alarm.STATE_STRINGS[alarmState]);
168:                sbuf.append(", sequenceNumber=").append(getSequenceNumber());
169:                sbuf.append(", timeStamp=").append(getTimeStamp());
170:                sbuf.append(", message=").append(getMessage());
171:                sbuf.append(", userData={").append(getUserData());
172:                sbuf.append("} ]");
173:
174:                return sbuf.toString();
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.