Source Code Cross Referenced for ModelMBeanConstructorInfo.java in  » JMX » jfoxmx » 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 » jfoxmx » javax.management.modelmbean 
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.modelmbean;
009:
010:        import java.lang.reflect.Constructor;
011:        import javax.management.Descriptor;
012:        import javax.management.MBeanParameterInfo;
013:        import javax.management.RuntimeOperationsException;
014:        import javax.management.DescriptorAccess;
015:        import javax.management.MBeanConstructorInfo;
016:
017:        /**
018:         * The ModelMBeanConstructorInfo object describes a constructor of the ModelMBean.
019:         * It is a subclass of MBeanConstructorInfo with the addition of an associated Descriptor
020:         * and an implementation of the DescriptorAccess interface.
021:         * <P>
022:         * <PRE>
023:         * The fields in the descriptor are defined, but not limited to, the following: <P>
024:         * name           : operation name
025:         * descriptorType : must be "operation"
026:         * role           : must be "constructor"
027:         * displayName    : human readable name of constructor
028:         * class          : class where method is defined (fully qualified)
029:         * visibility            : 1-4 where 1: always visible 4: rarely visible
030:         * presentationString :  xml formatted string to describe how to present operation
031:         *</PRE>
032:         * PersistencePolicy and CurrencyTimeLimit fields are not valid for the constructor.
033:         * The default constructo will have the name, descriptorType, and role fields.
034:         *
035:         * @author <a href="mailto:young_yy@hotmail.org">Young Yang</a>
036:         */
037:
038:        public class ModelMBeanConstructorInfo extends MBeanConstructorInfo
039:                implements  DescriptorAccess, Cloneable {
040:
041:            private Descriptor consDescriptor;
042:
043:            /**
044:             * Constructs a MBeanConstructorInfo object with a default descriptor.
045:             *
046:             * @param description A human readable description of the constructor.
047:             * @param constructor The java.lang.reflect.Method object describing the MBean constructor.
048:             */
049:            public ModelMBeanConstructorInfo(String description,
050:                    Constructor constructor) {
051:                super (description, constructor);
052:                consDescriptor = createDefaultDescriptor();
053:            }
054:
055:            /**
056:             * Constructs a MBeanConstructorInfo object.
057:             *
058:             * @param description A human readable description of the constructor.
059:             * @param constructor The java.lang.reflect.Method object describing the ModelMBean constructor.
060:             * @param descriptor An instance of Descriptor containing the appropriate metadata
061:             *                   for this instance of the ModelMBeanConstructorInfo. If it is null or invalid then
062:             *			a default desriptor will be created.
063:             */
064:            public ModelMBeanConstructorInfo(String description,
065:                    Constructor constructor, Descriptor descriptor) {
066:                super (description, constructor);
067:                setDescriptor(descriptor);
068:            }
069:
070:            /**
071:             * Constructs a ModelMBeanConstructorInfo object with a default descriptor.
072:             *
073:             * @param name The name of the constructor.
074:             * @param description A human readable description of the constructor.
075:             * @param signature MBeanParameterInfo object array describing the parameters(arguments) of the constructor.
076:             */
077:            public ModelMBeanConstructorInfo(String name, String description,
078:                    MBeanParameterInfo[] signature) {
079:                super (name, description, signature);
080:                consDescriptor = createDefaultDescriptor();
081:            }
082:
083:            /**
084:             * Constructs a MBeanConstructorInfo object.
085:             *
086:             * @param name The name of the constructor.
087:             * @param description A human readable description of the constructor.
088:             * @param signature MBeanParameterInfo objects describing the parameters(arguments) of the constructor.
089:             * @param descriptor An instance of Descriptor containing the appropriate metadata
090:             *                   for this instance of the MBeanConstructorInfo. If it is null or invalid then
091:             *			a default desriptor will be created.
092:             */
093:            public ModelMBeanConstructorInfo(String name, String description,
094:                    MBeanParameterInfo[] signature, Descriptor descriptor) {
095:                super (name, description, signature);
096:                setDescriptor(descriptor);
097:            }
098:
099:            /**
100:             * Constructs a new ModelMBeanConstructorInfo object from this ModelMBeanConstructor Object.
101:             *
102:             * @param constrInfo the ModelMBeanConstructorInfo to be duplicated
103:             *
104:             */
105:            ModelMBeanConstructorInfo(ModelMBeanConstructorInfo constrInfo) {
106:                super (constrInfo.getName(), constrInfo.getDescription(),
107:                        constrInfo.getSignature());
108:                consDescriptor = constrInfo.getDescriptor();
109:            }
110:
111:            /**
112:             * Creates and returns a new ModelMBeanConstructorInfo which is a duplicate of this ModelMBeanConstructorInfo.
113:             *
114:             */
115:            public Object clone() {
116:                return new ModelMBeanConstructorInfo(this );
117:            }
118:
119:            /**
120:             * Returns a copy of the associated Descriptor
121:             *
122:             * @return Descriptor associated with the ModelMBeanConstructorInfo object.
123:             */
124:            public Descriptor getDescriptor() {
125:                return (Descriptor) consDescriptor.clone();
126:            }
127:
128:            /**
129:             * Sets associated Descriptor (full replace) of ModelMBeanConstructorInfo.
130:             * If the new Descriptor is null, then the associated Descriptor reverts to
131:             * a default descriptor.  The Descriptor is validated before it is assigned.  If
132:             * the new Descriptor is invalid, then an IllegalArgumentException is thrown.
133:             *
134:             * @param descriptor - replaces the Descriptor associated with the
135:             * ModelMBeanConstructor.
136:             *
137:             */
138:            public void setDescriptor(Descriptor descriptor) {
139:                //     System.out.println("ModelMbeanConstructorInfo:61 " + descriptor.getFieldValue(DescriptorConstants.NAME) + " " +getNameSpace());
140:                if (descriptor == null) {
141:                    consDescriptor = createDefaultDescriptor();
142:                } else if (isValid(descriptor))
143:                    consDescriptor = (Descriptor) descriptor.clone();
144:                else
145:                    throw new RuntimeOperationsException(
146:                            new IllegalArgumentException(
147:                                    "Invalid descriptor passed in parameter"),
148:                            "Exception occured in ModelMBeanConstructorInfo setDescriptor");
149:            }
150:
151:            /**
152:             * Returns a string containing the entire contents of the ModelMBeanConstructorInfo in human readable form.
153:             */
154:            public String toString() {
155:                String desc = new String("ModelMBeanConstructorInfo: "
156:                        + getName() + " ; Description: " + getDescription()
157:                        + " ; Descriptor: " + getDescriptor()
158:                        + " ; Signature: ");
159:                MBeanParameterInfo[] signatures = getSignature();
160:                for (int i = 0; i < signatures.length; i++) {
161:                    desc += desc.concat(signatures[i].getType() + ", ");
162:                }
163:
164:                return desc;
165:            }
166:
167:            /**
168:             * Creates default descriptor for constructor as follows:
169:             * descriptorType=operation,role=constructor,
170:             * name=this.getNameSpace(),displayname=this.getNameSpace(),visibility=1
171:             */
172:            private Descriptor createDefaultDescriptor() {
173:                return new DescriptorSupport(
174:                        new String[] {
175:                                DescriptorConstants.DESCRIPTORTYPE + "="
176:                                        + DescriptorConstants.OPERATION_TYPE,
177:                                DescriptorConstants.OPERATION_ROLE
178:                                        + "="
179:                                        + DescriptorConstants.OPERATION_ROLE_CONSTRUCTOR,
180:                                DescriptorConstants.NAME + "=" + getName(),
181:                                DescriptorConstants.DISPLAYNAME + "="
182:                                        + getName() });
183:            }
184:
185:            /**
186:             * Tests that the descriptor is valid and adds appropriate default fields not already
187:             * specified. Field values must be correct for field names.
188:             * Descriptor must have the same name as the operation,the descriptorType field must
189:             * be "operation", the role field must be set to "constructor".
190:             * The following fields will be defaulted if they are not already set:
191:             * displayName=this.getNameSpace(),persistPolicy=never,visibility=1
192:             */
193:            private boolean isValid(Descriptor descriptor) {
194:                boolean isValid = true;
195:                if (descriptor == null) {
196:                    isValid = false;
197:                } else if (!descriptor.isValid()) {
198:                    isValid = false;
199:                } else {
200:                    if (!((String) descriptor
201:                            .getFieldValue(DescriptorConstants.NAME))
202:                            .equalsIgnoreCase(getName())) {
203:                        isValid = false;
204:                    }
205:                    if (!((String) descriptor
206:                            .getFieldValue(DescriptorConstants.DESCRIPTORTYPE))
207:                            .equalsIgnoreCase(DescriptorConstants.OPERATION_TYPE)) {
208:                        isValid = false;
209:                    }
210:                    if (descriptor
211:                            .getFieldValue(DescriptorConstants.OPERATION_ROLE) == null)
212:                        descriptor.setField(DescriptorConstants.OPERATION_ROLE,
213:                                DescriptorConstants.OPERATION_ROLE_CONSTRUCTOR);
214:                    if (!((String) descriptor
215:                            .getFieldValue(DescriptorConstants.OPERATION_ROLE))
216:                            .equalsIgnoreCase(DescriptorConstants.OPERATION_ROLE_CONSTRUCTOR)) {
217:                        isValid = false;
218:                    } else if (descriptor
219:                            .getFieldValue(DescriptorConstants.DISPLAYNAME) == null)
220:                        descriptor.setField(DescriptorConstants.DISPLAYNAME,
221:                                getName());
222:                }
223:                return isValid;
224:            }
225:
226:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.