Source Code Cross Referenced for OperationInfo.java in  » Library » Apache-commons-modeler-2.0.1-src » org » apache » commons » modeler » 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 » Library » Apache commons modeler 2.0.1 src » org.apache.commons.modeler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.commons.modeler;
019:
020:        import java.io.Serializable;
021:
022:        import javax.management.Descriptor;
023:        import javax.management.MBeanParameterInfo;
024:        import javax.management.modelmbean.ModelMBeanOperationInfo;
025:
026:        /**
027:         * <p>Internal configuration information for an <code>Operation</code>
028:         * descriptor.</p>
029:         *
030:         * @author Craig R. McClanahan
031:         * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $
032:         */
033:
034:        public class OperationInfo extends FeatureInfo implements  Serializable {
035:            static final long serialVersionUID = 4418342922072614875L;
036:
037:            // ----------------------------------------------------------- Constructors
038:
039:            /**
040:             * Standard zero-arguments constructor.
041:             */
042:            public OperationInfo() {
043:
044:                super ();
045:
046:            }
047:
048:            /**
049:             * Special constructor for setting up getter and setter operations.
050:             *
051:             * @param name Name of this operation
052:             * @param getter Is this a getter (as opposed to a setter)?
053:             * @param type Data type of the return value (if this is a getter)
054:             *  or the parameter (if this is a setter)
055:             * 
056:             */
057:            public OperationInfo(String name, boolean getter, String type) {
058:
059:                super ();
060:                setName(name);
061:                if (getter) {
062:                    setDescription("Attribute getter method");
063:                    setImpact("INFO");
064:                    setReturnType(type);
065:                    setRole("getter");
066:                } else {
067:                    setDescription("Attribute setter method");
068:                    setImpact("ACTION");
069:                    setReturnType("void");
070:                    setRole("setter");
071:                    addParameter(new ParameterInfo("value", type,
072:                            "New attribute value"));
073:                }
074:
075:            }
076:
077:            // ----------------------------------------------------- Instance Variables
078:
079:            /**
080:             * The <code>ModelMBeanOperationInfo</code> object that corresponds
081:             * to this <code>OperationInfo</code> instance.
082:             */
083:            transient ModelMBeanOperationInfo info = null;
084:            protected String impact = "UNKNOWN";
085:            protected String role = "operation";
086:            protected String returnType = "void"; // FIXME - Validate
087:            protected ParameterInfo parameters[] = new ParameterInfo[0];
088:
089:            // ------------------------------------------------------------- Properties
090:
091:            /**
092:             * Override the <code>description</code> property setter.
093:             *
094:             * @param description The new description
095:             */
096:            public void setDescription(String description) {
097:                super .setDescription(description);
098:                this .info = null;
099:            }
100:
101:            /**
102:             * Override the <code>name</code> property setter.
103:             *
104:             * @param name The new name
105:             */
106:            public void setName(String name) {
107:                super .setName(name);
108:                this .info = null;
109:            }
110:
111:            /**
112:             * The "impact" of this operation, which should be a (case-insensitive)
113:             * string value "ACTION", "ACTION_INFO", "INFO", or "UNKNOWN".
114:             */
115:            public String getImpact() {
116:                return (this .impact);
117:            }
118:
119:            public void setImpact(String impact) {
120:                if (impact == null)
121:                    this .impact = null;
122:                else
123:                    this .impact = impact.toUpperCase();
124:            }
125:
126:            /**
127:             * The role of this operation ("getter", "setter", "operation", or
128:             * "constructor").
129:             */
130:            public String getRole() {
131:                return (this .role);
132:            }
133:
134:            public void setRole(String role) {
135:                this .role = role;
136:            }
137:
138:            /**
139:             * The fully qualified Java class name of the return type for this
140:             * operation.
141:             */
142:            public String getReturnType() {
143:                return (this .returnType);
144:            }
145:
146:            public void setReturnType(String returnType) {
147:                this .returnType = returnType;
148:            }
149:
150:            /**
151:             * The set of parameters for this operation.
152:             */
153:            public ParameterInfo[] getSignature() {
154:                return (this .parameters);
155:            }
156:
157:            // --------------------------------------------------------- Public Methods
158:
159:            /**
160:             * Add a new parameter to the set of arguments for this operation.
161:             *
162:             * @param parameter The new parameter descriptor
163:             */
164:            public void addParameter(ParameterInfo parameter) {
165:
166:                synchronized (parameters) {
167:                    ParameterInfo results[] = new ParameterInfo[parameters.length + 1];
168:                    System.arraycopy(parameters, 0, results, 0,
169:                            parameters.length);
170:                    results[parameters.length] = parameter;
171:                    parameters = results;
172:                    this .info = null;
173:                }
174:
175:            }
176:
177:            /**
178:             * Create and return a <code>ModelMBeanOperationInfo</code> object that
179:             * corresponds to the attribute described by this instance.
180:             */
181:            public ModelMBeanOperationInfo createOperationInfo() {
182:
183:                // Return our cached information (if any)
184:                if (info != null)
185:                    return (info);
186:
187:                // Create and return a new information object
188:                ParameterInfo params[] = getSignature();
189:                MBeanParameterInfo parameters[] = new MBeanParameterInfo[params.length];
190:                for (int i = 0; i < params.length; i++)
191:                    parameters[i] = params[i].createParameterInfo();
192:                int impact = ModelMBeanOperationInfo.UNKNOWN;
193:                if ("ACTION".equals(getImpact()))
194:                    impact = ModelMBeanOperationInfo.ACTION;
195:                else if ("ACTION_INFO".equals(getImpact()))
196:                    impact = ModelMBeanOperationInfo.ACTION_INFO;
197:                else if ("INFO".equals(getImpact()))
198:                    impact = ModelMBeanOperationInfo.INFO;
199:
200:                info = new ModelMBeanOperationInfo(getName(), getDescription(),
201:                        parameters, getReturnType(), impact);
202:                Descriptor descriptor = info.getDescriptor();
203:                descriptor.removeField("class");
204:                descriptor.setField("role", getRole());
205:                addFields(descriptor);
206:                info.setDescriptor(descriptor);
207:                return (info);
208:
209:            }
210:
211:            /**
212:             * Return a string representation of this operation descriptor.
213:             */
214:            public String toString() {
215:
216:                StringBuffer sb = new StringBuffer("OperationInfo[");
217:                sb.append("name=");
218:                sb.append(name);
219:                sb.append(", description=");
220:                sb.append(description);
221:                sb.append(", returnType=");
222:                sb.append(returnType);
223:                sb.append(", parameters=");
224:                sb.append(parameters.length);
225:                sb.append("]");
226:                return (sb.toString());
227:
228:            }
229:
230:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.