Source Code Cross Referenced for ModelMBeanAttributeInfo.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.lang.reflect.Method;
029:        import java.io.ObjectInputStream;
030:        import java.io.ObjectOutputStream;
031:        import java.io.ObjectStreamField;
032:        import java.io.IOException;
033:
034:        import javax.management.Descriptor;
035:        import javax.management.DescriptorAccess;
036:        import javax.management.MBeanAttributeInfo;
037:        import javax.management.IntrospectionException;
038:
039:        /**
040:         * The ModelMBeanAttributeInfo object describes an attribute of the
041:         * ModelMBean. It is a subclass of MBeanAttributeInfo with the addition
042:         * of an associated Descriptor and an implementation of the DescriptorAccess
043:         * interface.
044:         * <p>
045:         * <p>
046:         * The fields in the descriptor are defined, but not limited to, the following:
047:         * <p>
048:         * <PRE>
049:         *	name           : attribute name
050:         *	descriptorType : must be "attribute"
051:         *	value          : current value for attribute
052:         *	default        : default value for attribute
053:         *	displayName    : name of attribute to be used in displays
054:         *	getMethod      : name of operation descriptor for get method
055:         *	setMethod      : name of operation descriptor for set method
056:         *	protocolMap    : object which implements the ProtocolMap interface: map of protocol names and protocol hints
057:         *	persistPolicy  : OnUpdate|OnTimer|NoMoreOftenThan|Always|Never
058:         *	persistPeriod  : seconds - frequency of persist cycle. Used when persistPolicy is"OnTimer" or "NoMoreOftenThan".
059:         *	currencyTimeLimit : how long value is valid, <0 never, =0 always, >0 seconds
060:         *	lastUpdatedTimeStamp : when value was set
061:         *	iterable       : T - object value supports Iterable interface, F - does not support Iterable interface
062:         *	visibility     : 1-4 where 1: always visible 4: rarely visible
063:         *	presentationString : xml formatted string to allow presentation of data
064:         * </PRE>
065:         * <p>The default descriptor contains the name and descriptorType fields.
066:         **/
067:        public class ModelMBeanAttributeInfo extends MBeanAttributeInfo
068:                implements  DescriptorAccess, Cloneable {
069:            String[] fieldNames = { "name", "descriptorType" };
070:            String[] fieldValues = { getName(), new String("attribute") };
071:
072:            Descriptor descriptor = new DescriptorSupport(fieldNames,
073:                    fieldValues);
074:
075:            private static final long serialVersionUID = 0x62814af8f0446c19L;
076:
077:            private static final ObjectStreamField[] serialPersistentFields = {
078:                    new ObjectStreamField("attrDescriptor",
079:                            DescriptorSupport.class),
080:                    new ObjectStreamField("currClass", java.lang.String.class)
081:
082:            };
083:
084:            /**
085:             * Constructs a ModelMBeanAttributeInfo object with a default descriptor.
086:             *
087:             * @param name The name of the attribute.
088:             *
089:             * @param description A human readable description of the attribute. Optional.
090:             *
091:             * @param getter The method used for reading the attribute value.
092:             * 				May be null if the property is write-only.
093:             *
094:             * @param setter The method used for writing the attribute value.
095:             *          	May be null if the attribute is read-only.
096:             *
097:             * @exception IntrospectionException There is a consistency problem in
098:             * 				the definition of this attribute.
099:             */
100:            public ModelMBeanAttributeInfo(String name, String description,
101:                    Method getter, Method setter) throws IntrospectionException {
102:                super (name, description, getter, setter);
103:            }
104:
105:            /**
106:             * Constructs a ModelMBeanAttributeInfo object.
107:             *
108:             * @param name The name of the attribute.
109:             *
110:             * @param description A human readable description of the attribute. Optional.
111:             *
112:             * @param getter The method used for reading the attribute value.
113:             *          	May be null if the property is write-only.
114:             *
115:             * @param setter The method used for writing the attribute value.
116:             *          	May be null if the attribute is read-only.
117:             *
118:             * @param descriptor An instance of Descriptor containing the appropriate
119:             * 				metadata for this instance of the Attribute. If it is null
120:             * 				or invalid then a default desriptor will be created.
121:             *
122:             * @exception IntrospectionException There is a consistency problem in
123:             * 				the definition of this attribute.
124:             */
125:            public ModelMBeanAttributeInfo(String name, String description,
126:                    Method getter, Method setter, Descriptor descriptor)
127:                    throws IntrospectionException {
128:                super (name, description, getter, setter);
129:                this .descriptor = descriptor;
130:            }
131:
132:            /**
133:             * Constructs a ModelMBeanAttributeInfo object with a default descriptor.
134:             *
135:             * @param name The name of the attribute
136:             *
137:             * @param type The type or class name of the attribute
138:             *
139:             * @param description A human readable description of the attribute.
140:             *
141:             * @param isReadable True if the attribute has a getter method, false otherwise.
142:             *
143:             * @param isWritable True if the attribute has a setter method, false otherwise.
144:             *
145:             * @param isIs True if the attribute has an "is" getter, false otherwise.
146:             */
147:            public ModelMBeanAttributeInfo(String name, String type,
148:                    String description, boolean isReadable, boolean isWritable,
149:                    boolean isIs) {
150:                super (name, type, description, isReadable, isWritable, isIs);
151:            }
152:
153:            /**
154:             * Constructs a ModelMBeanAttributeInfo object with a default descriptor.
155:             *
156:             * @param name The name of the attribute
157:             *
158:             * @param type The type or class name of the attribute
159:             *
160:             * @param description A human readable description of the attribute.
161:             *
162:             * @param isReadable True if the attribute has a getter method, false otherwise.
163:             *
164:             * @param isWritable True if the attribute has a setter method, false otherwise.
165:             *
166:             * @param isIs True if the attribute has an "is" getter, false otherwise.
167:             *
168:             * @param descriptor An instance of Descriptor containing the appropriate
169:             * 				metadata for this instance of the Attribute. If it is null
170:             * 				or invalid then a default desriptor will be created.
171:             */
172:            public ModelMBeanAttributeInfo(String name, String type,
173:                    String description, boolean isReadable, boolean isWritable,
174:                    boolean isIs, Descriptor descriptor) {
175:                super (name, type, description, isReadable, isWritable, isIs);
176:                this .descriptor = descriptor;
177:            }
178:
179:            /**
180:             * Constructs a new ModelMBeanAttributeInfo object from this
181:             * ModelMBeanAttributeInfo Object. A default descriptor will be created.
182:             *
183:             * @param inInfo the ModelMBeanAttributeInfo to be duplicated
184:             */
185:            public ModelMBeanAttributeInfo(ModelMBeanAttributeInfo inInfo) {
186:                super (inInfo.getName(), inInfo.getType(), inInfo
187:                        .getDescription(), inInfo.isReadable(), inInfo
188:                        .isWritable(), inInfo.isIs());
189:
190:                if (inInfo.getDescriptor() != null)
191:                    this .descriptor = (Descriptor) inInfo.getDescriptor()
192:                            .clone();
193:            }
194:
195:            /**
196:             * Creates and returns a new ModelMBeanAttributeInfo which is a
197:             * duplicate of this ModelMBeanAttributeInfo.
198:             *
199:             * @exception RuntimeOperationsException for illegal value for field Names
200:             * 				or field Values. If the descriptor construction fails for
201:             * 				any reason, this exception will be thrown.
202:             */
203:            public Object clone() {
204:                Descriptor clonedDescr = null;
205:
206:                if (descriptor != null)
207:                    clonedDescr = (Descriptor) descriptor.clone();
208:
209:                try {
210:                    return new ModelMBeanAttributeInfo(getName(), getType(),
211:                            getDescription(), isReadable(), isWritable(),
212:                            isIs(), clonedDescr);
213:                } catch (Exception e) {
214:                    return null;
215:                }
216:            }
217:
218:            /**
219:             * Gets a copy of the associated Descriptor for the ModelMBeanAttributeInfo
220:             *
221:             * @return Descriptor associated with the ModelMBeanAttributeInfo object.
222:             */
223:            public Descriptor getDescriptor() {
224:                return descriptor;
225:            }
226:
227:            /**
228:             * Sets associated Descriptor (full replace) for the
229:             * ModelMBeanAttributeDescriptor. If the new Descriptor is null, then the
230:             * associated Descriptor reverts to a default descriptor.  The Descriptor
231:             * is validated before it is assigned.  If the new Descriptor is invalid,
232:             * then an IllegalArgumentException is thrown.
233:             *
234:             * @param Descriptor inDescriptor - replaces the Descriptor associated
235:             * 				with the ModelMBeanAttributeInfo
236:             */
237:            public void setDescriptor(Descriptor inDescriptor) {
238:                this .descriptor = inDescriptor;
239:            }
240:
241:            /**
242:             * Returns a human readable version of the ModelMBeanAttributeInfo instance
243:             */
244:            public String toString() {
245:                if (descriptor != null)
246:                    return (super .toString() + "\n Descriptor = " + descriptor
247:                            .toString());
248:                else
249:                    return (super .toString() + "\n Descriptor = null");
250:            }
251:
252:            //--------------------------- Private methods ---------------------------//
253:
254:            private void readObject(ObjectInputStream objectinputstream)
255:                    throws IOException, ClassNotFoundException {
256:                ObjectInputStream.GetField getfield = objectinputstream
257:                        .readFields();
258:
259:                try {
260:                    descriptor = (DescriptorSupport) getfield.get(
261:                            "attrDescriptor", null);
262:                } catch (Exception exception) {
263:                    throw new IOException(exception.toString());
264:                }
265:            }
266:
267:            private void writeObject(ObjectOutputStream objectoutputstream)
268:                    throws IOException {
269:                ObjectOutputStream.PutField putfield = objectoutputstream
270:                        .putFields();
271:                putfield.put("attrDescriptor", descriptor);
272:                putfield.put("currClass", "ModelMBeanAttributeInfo");
273:
274:                objectoutputstream.writeFields();
275:            }
276:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.