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


001:        /* JFox, the OpenSource J2EE Application Server
002:         *
003:         * Copyright (C) 2002 huihoo.org
004:         * Distributable under GNU LGPL license
005:         * See the GNU Lesser General Public License for more details.
006:         */
007:
008:        package javax.management;
009:
010:        import java.io.Serializable;
011:        import java.lang.reflect.Method;
012:
013:        /**
014:         * Describes an MBean attribute exposed for management.
015:         *
016:         * @author <a href="mailto:young_yy@hotmail.org">Young Yang</a>
017:         */
018:
019:        public class MBeanAttributeInfo extends MBeanFeatureInfo implements 
020:                Serializable, Cloneable {
021:
022:            /**
023:             * The attribute read method.
024:             */
025:            private transient Method readMethod = null;
026:
027:            /**
028:             * The attribute write method.
029:             */
030:            private transient Method writeMethod = null;
031:
032:            /**
033:             * The actual attribute type.
034:             */
035:            private String attributeType = null;
036:
037:            /**
038:             * The attribute write right.
039:             */
040:            private boolean isWrite = false;
041:
042:            /**
043:             * The attribute read right.
044:             */
045:            private boolean isRead = false;
046:
047:            /**
048:             * Indicates if this method is a "is"
049:             */
050:            private boolean is = false;
051:
052:            /**
053:             * Constructs an <CODE>MBeanAttributeInfo</CODE> object.
054:             *
055:             * @param name The name of the attribute.
056:             * @param type The type or class name of the attribute.
057:             * @param description A human readable description of the attribute.
058:             * @param isReadable True if the attribute has a getter method, false otherwise.
059:             * @param isWritable True if the attribute has a setter method, false otherwise.
060:             * @param isIs True if this attribute has an "is" getter, false otherwise.
061:             *
062:             */
063:            public MBeanAttributeInfo(String name, String type,
064:                    String description, boolean isReadable, boolean isWritable,
065:                    boolean isIs) {
066:
067:                super (name, description);
068:                this .attributeType = type;
069:                this .isRead = isReadable;
070:                this .isWrite = isWritable;
071:                if (isIs && !isReadable) {
072:                    throw new IllegalArgumentException(
073:                            "Cannot have an \"is\" getter for a non-readable attribute.");
074:                }
075:                if (isIs
076:                        && (!type.equals("java.lang.Boolean") && (!type
077:                                .equals("boolean")))) {
078:                    throw new IllegalArgumentException(
079:                            "Cannot have an \"is\" getter for a non-boolean attribute.");
080:                }
081:                this .is = isIs;
082:
083:            }
084:
085:            /**
086:             * This constructor takes the name of a simple attribute, and Method
087:             * objects for reading and writing the attribute.
088:             *
089:             * @param name The programmatic name of the attribute.
090:             * @param description A human readable description of the attribute.
091:             * @param getter The method used for reading the attribute value.
092:             *          May be null if the property is write-only.
093:             * @param setter The method used for writing the attribute value.
094:             *          May be null if the attribute is read-only.
095:             * @exception IntrospectionException There is a consistency problem in the definition of this attribute.
096:             */
097:            public MBeanAttributeInfo(String name, String description,
098:                    Method getter, Method setter) throws IntrospectionException {
099:                super (name, description);
100:                this .readMethod = getter;
101:                this .writeMethod = setter;
102:                findAttributeType();
103:                findAttributeRights();
104:            }
105:
106:            /**
107:             * Package-private duplicate constructor.
108:             * <P>
109:             * This must isolate the new object from any changes to the mbeanAttributeInfo object.
110:             */
111:            MBeanAttributeInfo(MBeanAttributeInfo mbeanAttributeInfo) {
112:                super (mbeanAttributeInfo.name, mbeanAttributeInfo.description);
113:                attributeType = mbeanAttributeInfo.attributeType;
114:                isRead = mbeanAttributeInfo.isRead;
115:                isWrite = mbeanAttributeInfo.isWrite;
116:                is = mbeanAttributeInfo.is;
117:            }
118:
119:            /**
120:             * Creates and returns a copy of this object.
121:             */
122:            public Object clone() {
123:                return (new MBeanAttributeInfo(this ));
124:            }
125:
126:            /**
127:             * Returns the class name of the attribute.
128:             */
129:            public String getType() {
130:                return attributeType;
131:            }
132:
133:            /**
134:             * Whether the value of the attribute can be read.
135:             *
136:             * @return True if the attribute can be read, false otherwise.
137:             */
138:            public boolean isReadable() {
139:                return isRead;
140:            }
141:
142:            /**
143:             * Whether new values can be written to the attribute.
144:             *
145:             * @return True if the attribute can be written to, false otherwise.
146:             */
147:            public boolean isWritable() {
148:                return isWrite;
149:            }
150:
151:            /**
152:             * Indicates if this attribute has an "is" getter
153:             */
154:            public boolean isIs() {
155:                return is;
156:            }
157:
158:            /**
159:             * Sets the read/write rights of the attribute.
160:             */
161:            private void findAttributeRights() {
162:                if (readMethod != null) {
163:                    isRead = true;
164:                    if (readMethod.getName().startsWith("is")) {
165:                        is = true;
166:                    }
167:                }
168:                if (writeMethod != null) {
169:                    isWrite = true;
170:                }
171:            }
172:
173:            /**
174:             * Finds the type of the attribute.
175:             */
176:
177:            private void findAttributeType() throws IntrospectionException {
178:                Class type = null;
179:                try {
180:                    attributeType = null;
181:
182:                    if (readMethod != null) {
183:                        if (readMethod.getParameterTypes().length != 0) {
184:                            throw new IntrospectionException(
185:                                    "bad read method arg count");
186:                        }
187:                        type = readMethod.getReturnType();
188:                        if (type == Void.TYPE) {
189:                            throw new IntrospectionException("read method "
190:                                    + readMethod.getName() + " returns void");
191:                        }
192:                    }
193:
194:                    if (writeMethod != null) {
195:                        Class params[] = writeMethod.getParameterTypes();
196:                        if (params.length != 1) {
197:                            throw new IntrospectionException(
198:                                    "bad write method arg count");
199:                        }
200:                        if (type != null && type != params[0]) {
201:                            throw new IntrospectionException(
202:                                    "type mismatch between read and write methods");
203:                        }
204:                        type = params[0];
205:                    }
206:
207:                } catch (IntrospectionException ex) {
208:                    throw ex;
209:                }
210:                attributeType = type.getName();
211:            }
212:
213:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.