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


001:        /*
002:         * Copyright (C) The MX4J Contributors.
003:         * All rights reserved.
004:         *
005:         * This software is distributed under the terms of the MX4J License version 1.0.
006:         * See the terms of the MX4J License in the documentation provided with this software.
007:         */
008:
009:        package javax.management.modelmbean;
010:
011:        import java.lang.reflect.Constructor;
012:        import javax.management.Descriptor;
013:        import javax.management.DescriptorAccess;
014:        import javax.management.MBeanConstructorInfo;
015:        import javax.management.MBeanParameterInfo;
016:        import javax.management.RuntimeOperationsException;
017:
018:        /**
019:         * @version $Revision: 1.14 $
020:         */
021:        // Change not needed, workaround to a TCK bug only to achieve TCK compliance
022:        // public class ModelMBeanConstructorInfo extends MBeanConstructorInfo implements DescriptorAccess
023:        public class ModelMBeanConstructorInfo extends MBeanConstructorInfo
024:                implements  DescriptorAccess, Cloneable {
025:            private static final long serialVersionUID = 3862947819818064362L;
026:
027:            private Descriptor consDescriptor;
028:
029:            public ModelMBeanConstructorInfo(String description,
030:                    Constructor constructor) {
031:                this (description, constructor, null);
032:            }
033:
034:            public ModelMBeanConstructorInfo(String description,
035:                    Constructor constructor, Descriptor descriptor) {
036:                super (description, constructor);
037:                checkAndSetDescriptor(descriptor);
038:            }
039:
040:            public ModelMBeanConstructorInfo(String name, String description,
041:                    MBeanParameterInfo[] params) {
042:                this (name, description, params, null);
043:            }
044:
045:            public ModelMBeanConstructorInfo(String name, String description,
046:                    MBeanParameterInfo[] params, Descriptor descriptor) {
047:                super (name, description, params);
048:                checkAndSetDescriptor(descriptor);
049:            }
050:
051:            ModelMBeanConstructorInfo(ModelMBeanConstructorInfo copy) {
052:                super (copy.getName(), copy.getDescription(), copy
053:                        .getSignature());
054:                checkAndSetDescriptor(copy.getDescriptor());
055:            }
056:
057:            public Object clone() {
058:                return new ModelMBeanConstructorInfo(this );
059:            }
060:
061:            public Descriptor getDescriptor() {
062:                return (Descriptor) consDescriptor.clone();
063:            }
064:
065:            public void setDescriptor(Descriptor descriptor) {
066:                if (descriptor == null) {
067:                    consDescriptor = createDefaultDescriptor();
068:                } else {
069:                    if (isDescriptorValid(descriptor)) {
070:                        consDescriptor = (Descriptor) descriptor.clone();
071:                    } else {
072:                        // Not sure what to do here: javadoc says IllegalArgument, but for example ModelMBeanInfo throws RuntimeOperations
073:                        // which is consistent with the fact that all exception thrown by the JMX implementation should be JMX exceptions
074:                        throw new RuntimeOperationsException(
075:                                new IllegalArgumentException(
076:                                        "Invalid descriptor"));
077:                    }
078:                }
079:            }
080:
081:            private void checkAndSetDescriptor(Descriptor descriptor) {
082:                if (descriptor == null) {
083:                    consDescriptor = createDefaultDescriptor();
084:                } else if (isDescriptorValid(descriptor)) {
085:                    consDescriptor = (Descriptor) descriptor.clone();
086:                    if (consDescriptor.getFieldValue("displayName") == null) {
087:                        consDescriptor.setField("displayName", getName());
088:                    }
089:                } else {
090:                    throw new RuntimeOperationsException(
091:                            new IllegalArgumentException("Invalid descriptor"));
092:                }
093:            }
094:
095:            private boolean isDescriptorValid(Descriptor descriptor) {
096:                if (!descriptor.isValid()) {
097:                    return false;
098:                }
099:
100:                // Spec compliance checks
101:
102:                // Mandatory fields are: name, descriptorType, role
103:                String[] names = descriptor.getFieldNames();
104:
105:                if (!ModelMBeanInfoSupport.containsIgnoreCase(names, "name")
106:                        || !ModelMBeanInfoSupport.containsIgnoreCase(names,
107:                                "descriptortype")
108:                        || !ModelMBeanInfoSupport.containsIgnoreCase(names,
109:                                "role")) {
110:                    return false;
111:                }
112:
113:                if (ModelMBeanInfoSupport.containsIgnoreCase(names,
114:                        "persistpolicy")
115:                        || ModelMBeanInfoSupport.containsIgnoreCase(names,
116:                                "currencytimelimit")) {
117:                    return false;
118:                }
119:
120:                // Case sensitive name
121:                String name = getName();
122:                if (name == null) {
123:                    return false;
124:                }
125:                if (!name.equals(descriptor.getFieldValue("name"))) {
126:                    return false;
127:                }
128:                // Descriptor type must be 'operation'
129:                String desctype = (String) descriptor
130:                        .getFieldValue("descriptortype");
131:                if (desctype.compareToIgnoreCase("operation") != 0)
132:                    return false;
133:                // Role must be 'constructor'
134:                String role = (String) descriptor.getFieldValue("role");
135:                if (role.compareTo("constructor") != 0)
136:                    return false;
137:
138:                return true;
139:            }
140:
141:            private Descriptor createDefaultDescriptor() {
142:                String[] names = new String[] { "name", "descriptorType",
143:                        "role", "displayName"/*, "lastReturnedTimeStamp"*/};
144:                Object[] values = new Object[] { getName(), "operation",
145:                        "constructor", getName() /*, "0"*/};
146:                return new DescriptorSupport(names, values);
147:            }
148:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.