Source Code Cross Referenced for MBeanAttributeInfo.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.lang.reflect.Method;
029:        import java.io.Serializable;
030:        import java.io.ObjectInputStream;
031:        import java.io.ObjectInputStream.GetField;
032:        import java.io.ObjectOutputStream;
033:        import java.io.ObjectOutputStream.PutField;
034:        import java.io.ObjectStreamField;
035:        import java.io.IOException;
036:
037:        /**
038:         * Describes an MBean attribute exposed for management.
039:         */
040:        public class MBeanAttributeInfo extends MBeanFeatureInfo implements 
041:                Serializable, Cloneable {
042:            /**
043:             * The actual attribute type.
044:             */
045:            private String type = null;
046:
047:            /**
048:             * The attribute read right.
049:             */
050:            private boolean isReadable = true;
051:
052:            /**
053:             * Indicates if this method is a "is"
054:             */
055:            private boolean isIs = false;
056:
057:            /**
058:             * The attribute write right.
059:             */
060:            private boolean isWritable = true;
061:
062:            /**
063:             * The attribute read method.
064:             */
065:            private transient Method getter = null;
066:
067:            /**
068:             * The attribute write method.
069:             */
070:            private transient Method setter = null;
071:
072:            /* Serial version UID */
073:            private static final long serialVersionUID = 7043855487133450673L;
074:
075:            private static final ObjectStreamField[] serialPersistentFields = {
076:                    new ObjectStreamField("attributeType",
077:                            java.lang.String.class),
078:                    new ObjectStreamField("isWrite", java.lang.Boolean.TYPE),
079:                    new ObjectStreamField("isRead", java.lang.Boolean.TYPE),
080:                    new ObjectStreamField("is", java.lang.Boolean.TYPE), };
081:
082:            /**
083:             * Constructs an <CODE>MBeanAttributeInfo</CODE> object.
084:             *
085:             * @param name The name of the attribute.
086:             * @param type The type or class name of the attribute.
087:             * @param description A human readable description of the attribute.
088:             * @param isReadable True if the attribute has a getter method, false otherwise.
089:             * @param isWritable True if the attribute has a setter method, false otherwise.
090:             * @param is True if this attribute has an "is" getter, false otherwise.
091:             */
092:            public MBeanAttributeInfo(String name, String type,
093:                    String description, boolean isReadable, boolean isWritable,
094:                    boolean isIs) {
095:                super (name, description);
096:                this .type = type;
097:                this .isReadable = isReadable;
098:                this .isWritable = isWritable;
099:                this .isIs = isIs;
100:            }
101:
102:            /**
103:             * This constructor takes the name of a simple attribute, and Method
104:             * objects for reading and writing the attribute.
105:             *
106:             * @param name The programmatic name of the attribute.
107:             *
108:             * @param description A human readable description of the attribute.
109:             *
110:             * @param getter The method used for reading the attribute value.
111:             * 				May be null if the property is write-only.
112:             *
113:             * @param setter The method used for writing the attribute value.
114:             *          	May be null if the attribute is read-only.
115:             *
116:             * @exception IntrospectionException There is a consistency problem in
117:             * 				the definition of this attribute.
118:             */
119:            public MBeanAttributeInfo(String name, String description,
120:                    Method getter, Method setter) throws IntrospectionException {
121:                super (name, description);
122:
123:                if (getter == null)
124:                    isReadable = false;
125:                else if (getter.getName().startsWith("is"))
126:                    isIs = true;
127:
128:                if (setter == null)
129:                    isWritable = false;
130:
131:                this .getter = getter;
132:                this .setter = setter;
133:
134:                getAttributeType();
135:            }
136:
137:            private void getAttributeType() throws IntrospectionException {
138:                Class type = null;
139:                String gettername = null;
140:                String settername = null;
141:                String newgettername = null;
142:                String newsettername = null;
143:
144:                if (getter != null) {
145:                    if (getter.getParameterTypes().length != 0) {
146:                        throw new IntrospectionException("Invalid getter"
147:                                + getter.getName());
148:                    }
149:                    type = getter.getReturnType();
150:                    if (type == Void.TYPE) {
151:                        throw new IntrospectionException("Invalid getter"
152:                                + getter.getName());
153:                    }
154:
155:                    gettername = getter.getName();
156:
157:                    if (isIs)
158:                        newgettername = gettername.substring(2);
159:                    else
160:                        newgettername = gettername.substring(3);
161:                }
162:
163:                if (setter != null) {
164:                    Class params[] = setter.getParameterTypes();
165:
166:                    if (params.length != 1) {
167:                        throw new IntrospectionException("Invalid setter"
168:                                + setter.getName());
169:                    }
170:                    if (type != null && type != params[0]) {
171:                        throw new IntrospectionException("Invalid setter"
172:                                + setter.getName());
173:                    }
174:
175:                    type = params[0];
176:                    if (name != null) {
177:                        settername = setter.getName();
178:                        newsettername = settername.substring(3);
179:
180:                        if (getter != null) {
181:                            if (!newgettername.equals(newsettername)) {
182:                                throw new IntrospectionException(
183:                                        "Difference in getter and setter name");
184:                            }
185:                        }
186:                    }
187:                }
188:
189:                if (type != null) {
190:                    this .type = type.getName();
191:                }
192:            }
193:
194:            /**
195:             * Returns the class name of the attribute.
196:             *
197:             * @return The class name is returned as String
198:             */
199:            public String getType() {
200:                return type;
201:            }
202:
203:            /**
204:             * Whether the value of the attribute can be read.
205:             *
206:             * @return True if the attribute can be read, false otherwise.
207:             */
208:
209:            public boolean isReadable() {
210:                return isReadable;
211:            }
212:
213:            /**
214:             * Whether new values can be written to the attribute.
215:             *
216:             * @return True if the attribute can be written, false otherwise.
217:             */
218:
219:            public boolean isWritable() {
220:                return isWritable;
221:            }
222:
223:            /**
224:             * Indicates if this attribute has an "is" getter
225:             * @return True if the attribute has an "is" getter otherwise false
226:             */
227:            public boolean isIs() {
228:                return isIs;
229:            }
230:
231:            /**
232:             * Creates and returns a copy of this object.
233:             *
234:             * @return Creates a duplicate copy of the object
235:             */
236:            public Object clone() {
237:                return new MBeanAttributeInfo(getName(), type,
238:                        getDescription(), isReadable, isWritable, isIs);
239:            }
240:
241:            /**
242:             * Returns a human readable version of the MBeanAttributeInfo instance.
243:             *
244:             * @return MBeanAttributeInfo is returned as a String
245:             */
246:            public String toString() {
247:                return (super .toString() + "\n Type = " + type
248:                        + "\n IsReadable = "
249:                        + new Boolean(isReadable).toString()
250:                        + "\n IsWritable = "
251:                        + new Boolean(isWritable).toString() + "\n IsIs = " + new Boolean(
252:                        isIs).toString());
253:            }
254:
255:            //------------------------- Private methods ---------------------------//
256:
257:            private void readObject(ObjectInputStream objectinputstream)
258:                    throws IOException, ClassNotFoundException {
259:                ObjectInputStream.GetField getfield = objectinputstream
260:                        .readFields();
261:
262:                try {
263:                    type = (String) getfield.get("attributeType", "");
264:                    isWritable = getfield.get("isWrite", false);
265:                    isReadable = getfield.get("isRead", false);
266:                    isIs = getfield.get("is", false);
267:                } catch (Exception exception) {
268:                }
269:            }
270:
271:            private void writeObject(ObjectOutputStream objectoutputstream)
272:                    throws IOException {
273:                ObjectOutputStream.PutField putfield = objectoutputstream
274:                        .putFields();
275:                putfield.put("attributeType", type);
276:                putfield.put("isWrite", isWritable);
277:                putfield.put("isRead", isReadable);
278:                putfield.put("is", isIs);
279:                objectoutputstream.writeFields();
280:            }
281:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.