Source Code Cross Referenced for ModelMBeanNotificationInfo.java in  » JMX » XMOJO » javax » management » modelmbean » 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.modelmbean 
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.modelmbean;
027:
028:        import java.io.ObjectInputStream;
029:        import java.io.ObjectOutputStream;
030:        import java.io.ObjectStreamField;
031:        import java.io.IOException;
032:
033:        import javax.management.Descriptor;
034:        import javax.management.DescriptorAccess;
035:        import javax.management.MBeanNotificationInfo;
036:
037:        /**
038:         * The ModelMBeanNotificationInfo object describes a notification emitted
039:         * by a ModelMBean. It is a subclass of MBeanNotificationInfo with the
040:         * addition of an associated Descriptor and an implementation of the
041:         * Descriptor interface.
042:         * <P>
043:         * <P>
044:         * <PRE>
045:         * The fields in the descriptor are defined, but not limited to, the following: <P>
046:         *	name           : notification name <P>
047:         *	descriptorType : must be "notification"   <P>
048:         *	severity       : 1-5 where 1: fatal 2: severe 3: error 4: warn 5: info  <P>
049:         *	messageID      : unique key for message text (to allow translation,analysis)  <P>
050:         *	messageText    : text of notification   <P>
051:         *	log            : T - log message F - do not log message   <P>
052:         *	logfile        : string fully qualified file name appropriate for operating system<P>
053:         *	visibility     : 1-4 where 1: always visible 4: rarely visible   <P>
054:         *	presentationString : xml formatted string to allow presentation of data  <P>
055:         * </PRE>
056:         * <P> The default descriptor contains the name, descriptorType, and severity=5 fields.
057:         */
058:        public class ModelMBeanNotificationInfo extends MBeanNotificationInfo
059:                implements  DescriptorAccess, Cloneable {
060:            Descriptor descriptor = new DescriptorSupport();
061:
062:            static final long serialVersionUID = -5304849168906325029L;
063:
064:            private static final ObjectStreamField[] serialPersistentFields = {
065:                    new ObjectStreamField("notificationDescriptor",
066:                            DescriptorSupport.class),
067:                    new ObjectStreamField("currClass", java.lang.String.class) };
068:
069:            /**
070:             * Constructs a ModelMBeanNotificationInfo object with a default descxriptor.
071:             *
072:             * @param notifTypes The notification type string
073:             *
074:             * @param name The Notification class name
075:             *
076:             * @param description The description about the notification
077:             */
078:            public ModelMBeanNotificationInfo(String[] notifTypes, String name,
079:                    String description) {
080:                super (notifTypes, name, description);
081:                this .descriptor = getDefaultDescriptor();
082:            }
083:
084:            /**
085:             * Constructs a ModelMBeanNotificationInfo object
086:             *
087:             * @param notifTypes The notification type string
088:             *
089:             * @param name The Notification class name
090:             *
091:             * @param description The description about the notification
092:             *
093:             * @param descriptor  Descriptor containing the appropriate metadata for
094:             * 				this instance of the MBeanNotificationInfo. If it is null
095:             * 				or invalid then a default desriptor will be created.
096:             */
097:            public ModelMBeanNotificationInfo(String[] notifTypes, String name,
098:                    String description, Descriptor descriptor) {
099:                super (notifTypes, name, description);
100:
101:                if (descriptor.isValid())
102:                    this .descriptor = descriptor;
103:                else
104:                    this .descriptor = getDefaultDescriptor();
105:            }
106:
107:            /**
108:             * Constructs a new ModelMBeanNotificationInfo object from this
109:             * ModelMBeanNotfication Object.
110:             *
111:             * @param inInfo The duplicate ModelMBeanNotificationInfo object
112:             */
113:            public ModelMBeanNotificationInfo(ModelMBeanNotificationInfo inInfo) {
114:                super (inInfo.getNotifTypes(), inInfo.getName(), inInfo
115:                        .getDescription());
116:
117:                if (inInfo.getDescriptor() != null)
118:                    this .descriptor = (Descriptor) inInfo.getDescriptor()
119:                            .clone();
120:                else
121:                    this .descriptor = getDefaultDescriptor();
122:            }
123:
124:            /**
125:             * Creates a duplicate ModelMBeanNotificationInfo object
126:             *
127:             * @return A duplicate ModelMBeanNotificationInfo object
128:             */
129:            public Object clone() {
130:                Descriptor clonedDescr = null;
131:
132:                if (descriptor != null)
133:                    clonedDescr = (Descriptor) descriptor.clone();
134:
135:                return new ModelMBeanNotificationInfo(getNotifTypes(),
136:                        getName(), getDescription(), clonedDescr);
137:            }
138:
139:            /**
140:             * Gets the corresponding Descriptor of this ModelMBeanNotificationInfo
141:             *
142:             * @return This returns the Descriptor associated with
143:             * 				this ModelMBeanNotificationInfo
144:             */
145:            public Descriptor getDescriptor() {
146:                return descriptor;
147:            }
148:
149:            /**
150:             * Sets the specified Descriptor to this ModelMBeanNotificationInfo.If the
151:             * value is null then default Descriptor will be taken.  The Descriptor
152:             * is validated before it is assigned. If the new Descriptor is invalid,
153:             * then an IllegalArgumentException is thrown.
154:             *
155:             * @param inDescriptor This replaces the Descriptor associated with the
156:             * 				ModelMBeanNotification interface
157:             *
158:             * @throws IllegalArgumentException If the new Descriptor is invalid,
159:             * 				then it will be thrown.
160:             */
161:            public void setDescriptor(Descriptor inDescriptor) {
162:                if (inDescriptor == null) {
163:                    this .descriptor = getDefaultDescriptor();
164:                } else {
165:                    if (inDescriptor.isValid())
166:                        this .descriptor = (Descriptor) inDescriptor.clone();
167:                    else
168:                        throw new IllegalArgumentException(
169:                                "Invalid descriptor received as parameter");
170:                }
171:            }
172:
173:            /**
174:             * Returns a human readable version of the ModelMBeanNotificationInfo instance
175:             * @return  Human readable version of the ModelMBeanNotificationInfo instance
176:             */
177:            public String toString() {
178:                if (descriptor != null)
179:                    return (super .toString() + "\n Descriptor = " + descriptor
180:                            .toString());
181:                else
182:                    return (super .toString() + "\n Descriptor = null");
183:            }
184:
185:            //--------------------------- Private methods ---------------------------//
186:
187:            /**
188:             * Creates default descriptor for notification as follows:
189:             * descriptorType=notification, name=this.getName(),
190:             * displayname=this.getName(),log=F,severity=5,visibility=1
191:             */
192:            private Descriptor getDefaultDescriptor() {
193:                return new DescriptorSupport(new String[] {
194:                        "descriptorType=notification",
195:                        ("name=" + this .getName()),
196:                        ("displayName=" + this .getName()), "severity=5",
197:                        "log=F", "visibility=1" });
198:            }
199:
200:            private void readObject(ObjectInputStream objectinputstream)
201:                    throws IOException, ClassNotFoundException {
202:                ObjectInputStream.GetField getfield = objectinputstream
203:                        .readFields();
204:
205:                try {
206:                    descriptor = (DescriptorSupport) getfield.get(
207:                            "notificationDescriptor", null);
208:                } catch (Exception exception) {
209:                    //throw new IOException(malformedobjectnameexception.toString());
210:                }
211:            }
212:
213:            private void writeObject(ObjectOutputStream objectoutputstream)
214:                    throws IOException {
215:                ObjectOutputStream.PutField putfield = objectoutputstream
216:                        .putFields();
217:                putfield.put("notificationDescriptor", descriptor);
218:                putfield.put("currClass", "ModelMBeanNotificationInfo");
219:
220:                objectoutputstream.writeFields();
221:            }
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.