Source Code Cross Referenced for Notification.java in  » JMX » XMOJO » javax » management » 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 » JMX » XMOJO » javax.management 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * The XMOJO Project 5
003:         * Copyright © 2003 XMOJO.org. All rights reserved.
004:
005:         * NO WARRANTY
006:
007:         * BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
008:         * THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
009:         * OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
010:         * PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
011:         * OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
012:         * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
013:         * TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE
014:         * LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
015:         * REPAIR OR CORRECTION.
016:
017:         * IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
018:         * ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
019:         * THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
020:         * GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
021:         * USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF
022:         * DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
023:         * PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE),
024:         * EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
025:         * SUCH DAMAGES.
026:         **/package javax.management;
027:
028:        import java.io.Serializable;
029:        import java.io.ObjectInputStream;
030:        import java.io.ObjectInputStream.GetField;
031:        import java.io.ObjectOutputStream;
032:        import java.io.ObjectOutputStream.PutField;
033:        import java.io.ObjectStreamField;
034:        import java.io.IOException;
035:        import java.util.EventObject;
036:
037:        /**
038:         * The Notification class represents a notification emitted by an MBean.
039:         * It contains a reference to the source MBean: if the notification has been
040:         * forwarded through the MBean server, this is the object name of the MBean.
041:         * If the listener has registered directly with the MBean, this is a
042:         * direct reference to the MBean.
043:         */
044:        public class Notification extends EventObject //implements Serializable
045:        {
046:            /* Serial version UID */
047:            private static final long serialVersionUID = 1716977971058914352L;
048:
049:            /**
050:             * The notification message.
051:             */
052:            private String message = "Notification ...";
053:
054:            /**
055:             * The notification type. A string expressed in a dot notation similar to
056:             * Java properties. An example of notification type is network.alarm.router
057:             */
058:            private String type = null;
059:
060:            /**
061:             * The object on which the notification initially occurred.
062:             */
063:            protected Object source = null;
064:
065:            /**
066:             * The notification sequence number. A serial number which identify
067:             * particular instance of notification in the context of notification source.
068:             */
069:            private long sequenceNumber = 0;
070:
071:            /**
072:             * The notification timestamp. Indicating when the notification was generated
073:             */
074:            private long timeStamp = 0;
075:
076:            /**
077:             * The notification user data.  Used for whatever other data the
078:             * notification source wishes to communicate to its consumers.
079:             */
080:            private Object userData = null;
081:
082:            /**
083:             * Creates a Notification object. The notification timeStamp is set to
084:             * the curent date.
085:             *
086:             * @param type The notification type.
087:             *
088:             * @param source The notification source.
089:             *
090:             * @param sequenceNumber The notification sequence number within the source object.
091:             */
092:            public Notification(String type, Object source, long sequenceNumber) {
093:                super (source);
094:                this .type = type;
095:                this .source = source;
096:                this .sequenceNumber = sequenceNumber;
097:                this .timeStamp = System.currentTimeMillis();
098:            }
099:
100:            /**
101:             * Creates a Notification object. The notification timeStamp is set to
102:             * the curent date.
103:             *
104:             * @param type The notification type.
105:             *
106:             * @param source The notification source.
107:             *
108:             * @param sequenceNumber The notification sequence number within the source object.
109:             *
110:             * @param message the detail message.
111:             */
112:            public Notification(String type, Object source,
113:                    long sequenceNumber, String message) {
114:                super (source);
115:                this .type = type;
116:                this .source = source;
117:                this .sequenceNumber = sequenceNumber;
118:                this .message = message;
119:                this .timeStamp = System.currentTimeMillis();
120:            }
121:
122:            /**
123:             * Creates a Notification object.
124:             *
125:             * @param type The notification type.
126:             *
127:             * @param source The notification source.
128:             *
129:             * @param sequenceNumber The notification sequence number within the source object.
130:             *
131:             * @param timeStamp The notification emission date.
132:             **/
133:            public Notification(String type, Object source,
134:                    long sequenceNumber, long timeStamp) {
135:                super (source);
136:                this .type = type;
137:                this .source = source;
138:                this .sequenceNumber = sequenceNumber;
139:                this .timeStamp = timeStamp;
140:            }
141:
142:            /**
143:             * Creates a Notification object.
144:             *
145:             * @param type The notification type.
146:             *
147:             * @param source The notification source.
148:             *
149:             * @param sequenceNumber The notification sequence number within the source object.
150:             *
151:             * @param timeStamp The notification emission date.
152:             *
153:             * @param message the detail message.
154:             */
155:            public Notification(String type, Object source,
156:                    long sequenceNumber, long timeStamp, String message) {
157:                super (source);
158:                this .type = type;
159:                this .source = source;
160:                this .sequenceNumber = sequenceNumber;
161:                this .timeStamp = timeStamp;
162:                this .message = message;
163:            }
164:
165:            /**
166:             * Get the notification message.
167:             *
168:             * @return The message string of this notification object.
169:             */
170:            public String getMessage() {
171:                return message;
172:            }
173:
174:            /**
175:             * Get the notification sequence number.
176:             *
177:             * @return The notification sequence number within the source object.
178:             */
179:            public long getSequenceNumber() {
180:                return sequenceNumber;
181:            }
182:
183:            /**
184:             * Set the notification sequence number.
185:             *
186:             * @param sequenceNumber set the notification sequence number
187:             * 				within the source object
188:             */
189:            public void setSequenceNumber(long sequenceNumber) {
190:                this .sequenceNumber = sequenceNumber;
191:            }
192:
193:            /**
194:             * Get the notification timestamp.
195:             *
196:             * @return The notification timestamp.
197:             */
198:            public long getTimeStamp() {
199:                return timeStamp;
200:            }
201:
202:            /**
203:             * Set the notification timestamp.
204:             *
205:             * @param timeStamp set the notification emission date
206:             */
207:            public void setTimeStamp(long timeStamp) {
208:                this .timeStamp = timeStamp;
209:            }
210:
211:            /**
212:             * Get the notification type.
213:             *
214:             * @return The notification type.
215:             */
216:            public String getType() {
217:                return type;
218:            }
219:
220:            /**
221:             * Get the user data.
222:             *
223:             * @return The user data object
224:             */
225:            public Object getUserData() {
226:                return userData;
227:            }
228:
229:            /**
230:             * Set the source.
231:             *
232:             * @param source Set the source object.
233:             *
234:             * @exception java.lang.IllegalArgumentException The source is not a ObjectName
235:             */
236:            public void setSource(Object source)
237:                    throws IllegalArgumentException {
238:                if (!(source instanceof  ObjectName)) {
239:                    throw new java.lang.IllegalArgumentException(
240:                            "Source is not an instance of javax.management.ObjectName");
241:                }
242:
243:                this .source = source;
244:            }
245:
246:            /**
247:             * Set the user data.
248:             *
249:             * @param userData set the user data object
250:             */
251:            public void setUserData(Object userData) {
252:                this .userData = userData;
253:            }
254:
255:            /**
256:             * Get the source Object.
257:             *
258:             * @return The source object.
259:             */
260:            public Object getSource() {
261:                return source;
262:            }
263:
264:            public String toString() {
265:                StringBuffer b = new StringBuffer("[");
266:                b.append("Source = ").append(getSource()).append(", ");
267:                b.append("Message = ").append(getMessage()).append(", ");
268:                b.append("Sequence number = ").append(getSequenceNumber())
269:                        .append(", ");
270:                b.append("Notification type = ").append(getType()).append(", ");
271:                b.append("Time = ").append(getTimeStamp()).append(", ");
272:                b.append("User data = ").append(getUserData());
273:                b.append("]");
274:                return b.toString();
275:            }
276:
277:            //------------------------- Private methods ---------------------------//
278:
279:            private void readObject(ObjectInputStream objectinputstream)
280:                    throws IOException, ClassNotFoundException {
281:                ObjectInputStream.GetField getfield = objectinputstream
282:                        .readFields();
283:
284:                try {
285:                    message = (String) getfield.get("message",
286:                            "Notification...");
287:                    sequenceNumber = getfield.get("sequenceNumber", 0l);
288:                    source = (Object) getfield.get("source", null);
289:                    type = (String) getfield.get("type", null);
290:                    timeStamp = getfield.get("timeStamp", System
291:                            .currentTimeMillis());
292:                    userData = (Object) getfield.get("userData", null);
293:                } catch (Exception exception) {
294:                    exception.printStackTrace();
295:                }
296:            }
297:
298:            private void writeObject(ObjectOutputStream objectoutputstream)
299:                    throws IOException {
300:                ObjectOutputStream.PutField putfield = objectoutputstream
301:                        .putFields();
302:
303:                putfield.put("message", getMessage());
304:                putfield.put("sequenceNumber", getSequenceNumber());
305:                putfield.put("source", getSource());
306:                putfield.put("timeStamp", getTimeStamp());
307:                putfield.put("userData", getUserData());
308:                putfield.put("type", getType());
309:
310:                objectoutputstream.writeFields();
311:            }
312:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.