Source Code Cross Referenced for RoleInfo.java in  » JMX » jfoxmx » javax » management » relation » 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.relation 
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.relation;
009:
010:        import java.io.Serializable;
011:        import javax.management.NotCompliantMBeanException;
012:
013:        /**
014:         * A RoleInfo object represents a role information in a relation type.
015:         *
016:         * @author <a href="mailto:young_yy@hotmail.org">Young Yang</a>
017:         */
018:
019:        public class RoleInfo implements  Serializable {
020:
021:            /**
022:             * To specify an unlimited cardinality, -1
023:             */
024:            public final static int ROLE_CARDINALITY_INFINITY = -1;
025:
026:            // Name of the role
027:            private String name = null;
028:
029:            // Read access mode: true if role is readable
030:            private boolean readable = true;
031:
032:            // Write access mode: true if role is writable
033:            private boolean writable = true;
034:
035:            // Description of role
036:            private String description = null;
037:
038:            // Minimum degree (i.e. minimum number of referenced MBeans in
039:            // corresponding role)
040:            private int minDegree = 1;
041:
042:            // Maximum degree (i.e. maximum number of referenced MBeans in
043:            // corresponding role)
044:            private int maxDegree = 1;
045:
046:            // Name of class of MBean(s) expected to be referenced in corresponding
047:            // role
048:            private String refMBeanClassName = null;
049:
050:            /**
051:             * Constructor
052:             *
053:             * @param name  name of the role
054:             * @param refMBeanClassName  name of the class of MBean(s) expected to
055:             * be referenced in corresponding role
056:             * @param readable  flag to indicate if the corresponding role
057:             * can be read
058:             * @param writable  flag to indicate if the corresponding role
059:             * can be set
060:             * @param minDegree  minimum degree for role, i.e. minimum number of
061:             * MBeans to provide in corresponding role
062:             * Must be less or equal than maxDegree.
063:             * (ROLE_CARDINALITY_INFINITY for unlimited)
064:             * @param maxDegree  maximum degree for role, i.e. maximum number of
065:             * MBeans to provide in corresponding role
066:             * Must be greater or equal than minDegree
067:             * (ROLE_CARDINALITY_INFINITY for unlimited)
068:             * @param description  description of the role (can be null)
069:             *
070:             * @exception IllegalArgumentException  if null parameter
071:             * @exception InvalidRoleInfoException  if the minimum degree is
072:             * greater than the maximum degree.
073:             * @exception ClassNotFoundException  if the class refMBeanClassName
074:             * does not exist.
075:             * @exception NotCompliantMBeanException  if the class refMBeanClassName
076:             * is not a MBean class.
077:             */
078:            public RoleInfo(String name, String refMBeanClassName,
079:                    boolean readable, boolean writable, int minDegree,
080:                    int maxDegree, String description)
081:                    throws IllegalArgumentException, InvalidRoleInfoException,
082:                    ClassNotFoundException, NotCompliantMBeanException {
083:
084:                if (maxDegree < ROLE_CARDINALITY_INFINITY
085:                        || minDegree < ROLE_CARDINALITY_INFINITY) { // cant not less than the infinity value
086:                    throw new InvalidRoleInfoException(
087:                            "Minimum or maximum degree has an illegal value, must be [0, ROLE_CARDINALITY_INFINITY].");
088:                }
089:
090:                if (maxDegree > ROLE_CARDINALITY_INFINITY
091:                        && (minDegree == ROLE_CARDINALITY_INFINITY || minDegree > maxDegree)) { // maxDegree >= 0
092:                    throw new InvalidRoleInfoException("Minimum degree "
093:                            + minDegree + " is greater than maximum degree "
094:                            + maxDegree);
095:                }
096:
097:                init(name, refMBeanClassName, readable, writable, minDegree,
098:                        maxDegree, description);
099:            }
100:
101:            /**
102:             * Constructor with 1 minDegree and 1 maxDegree,null description
103:             *
104:             */
105:            public RoleInfo(String name, String refMBeanClassName,
106:                    boolean readable, boolean writable)
107:                    throws IllegalArgumentException, ClassNotFoundException,
108:                    NotCompliantMBeanException {
109:                init(name, refMBeanClassName, readable, writable, 1, 1, null);
110:            }
111:
112:            /**
113:             * Constructor with true readable,true writable,1 minDegree,1 maxDegree,null description
114:             *
115:             */
116:            public RoleInfo(String theName, String theRefMBeanClassName)
117:                    throws IllegalArgumentException, ClassNotFoundException,
118:                    NotCompliantMBeanException {
119:                init(theName, theRefMBeanClassName, true, true, 1, 1, null);
120:            }
121:
122:            /**
123:             * Copy constructor
124:             *
125:             * @exception IllegalArgumentException  if null parameter
126:             */
127:            public RoleInfo(RoleInfo roleInfo) throws IllegalArgumentException {
128:
129:                if (roleInfo == null)
130:                    throw new IllegalArgumentException(
131:                            "Invalid parameter: roleInfo is null");
132:
133:                try {
134:                    init(roleInfo.getName(), roleInfo.getRefMBeanClassName(),
135:                            roleInfo.isReadable(), roleInfo.isWritable(),
136:                            roleInfo.getMinDegree(), roleInfo.getMaxDegree(),
137:                            roleInfo.getDescription());
138:                } catch (NotCompliantMBeanException e) {
139:                } catch (ClassNotFoundException e) {
140:                }
141:            }
142:
143:            /**
144:             * Returns the name of the role
145:             */
146:            public String getName() {
147:                return name;
148:            }
149:
150:            /**
151:             * Returns read access mode for the role (true if it is readable)
152:             */
153:            public boolean isReadable() {
154:                return readable;
155:            }
156:
157:            /**
158:             * Returns write access mode for the role (true if it is writable)
159:             */
160:            public boolean isWritable() {
161:                return writable;
162:            }
163:
164:            /**
165:             * Returns description text for the role
166:             */
167:            public String getDescription() {
168:                return description;
169:            }
170:
171:            /**
172:             * Returns minimum degree for corresponding role reference
173:             */
174:            public int getMinDegree() {
175:                return minDegree;
176:            }
177:
178:            /**
179:             * Returns maximum degree for corresponding role reference
180:             */
181:            public int getMaxDegree() {
182:                return maxDegree;
183:            }
184:
185:            /**
186:             * Returns name of class of MBean expected to be referenced in
187:             * corresponding role
188:             */
189:            public String getRefMBeanClassName() {
190:                return refMBeanClassName;
191:            }
192:
193:            /**
194:             * Returns a boolean to specify if given value is greater or equal than
195:             * expected minimum degree (true if yes)
196:             *
197:             * @param value  value
198:             *
199:             * @return true if greater or equal than minimum degree, false else
200:             */
201:            public boolean checkMinDegree(int value) {
202:
203:                if (value < ROLE_CARDINALITY_INFINITY) {
204:                    return false;
205:                } else if (value == ROLE_CARDINALITY_INFINITY) {
206:                    if (minDegree != ROLE_CARDINALITY_INFINITY)
207:                        return false;
208:                } else {
209:                    if (minDegree != ROLE_CARDINALITY_INFINITY
210:                            && value < minDegree)
211:                        return false;
212:                }
213:
214:                return true;
215:
216:            }
217:
218:            /**
219:             * Returns a boolean to specify if given value is less or equal than
220:             * expected maximum degree (true if yes)
221:             *
222:             * @param value  value
223:             *
224:             * @return true if less or equal than maximum degree, false else
225:             */
226:            public boolean checkMaxDegree(int value) {
227:                if (value < ROLE_CARDINALITY_INFINITY) {
228:                    return false;
229:                } else if (value == ROLE_CARDINALITY_INFINITY) {
230:                    if (maxDegree != ROLE_CARDINALITY_INFINITY)
231:                        return false;
232:                } else {
233:                    if (maxDegree != ROLE_CARDINALITY_INFINITY
234:                            && value > maxDegree)
235:                        return false;
236:                }
237:                return true;
238:
239:            }
240:
241:            /**
242:             * Prints a string describing the role info
243:             */
244:            public String toString() {
245:                StringBuffer result = new StringBuffer();
246:                result.append("role info name: " + name);
247:                result.append("; isReadable: " + readable);
248:                result.append("; isWritable: " + writable);
249:                result.append("; description: " + description);
250:                result.append("; minimum degree: " + minDegree);
251:                result.append("; maximum degree: " + maxDegree);
252:                result.append("; MBean class: " + refMBeanClassName);
253:                return result.toString();
254:            }
255:
256:            // Initialisation
257:            private void init(String name, String refMBeanClassName,
258:                    boolean readable, boolean writable, int minDegree,
259:                    int maxDegree, String description)
260:                    throws IllegalArgumentException, ClassNotFoundException,
261:                    NotCompliantMBeanException {
262:
263:                if (name == null || refMBeanClassName == null) {
264:                    throw new IllegalArgumentException(
265:                            "Invalid parameter: name & refMBeanClassName can not be null");
266:                }
267:
268:                this .name = name;
269:                this .readable = readable;
270:                this .writable = writable;
271:                this .description = description;
272:                this .minDegree = minDegree;
273:                this .maxDegree = maxDegree;
274:
275:                // Checks if class name provided for expected MBeans corresponds to
276:                // a class which exists
277:                // Can throw a ClassNotFoundException
278:                //    Class refMBeanClass = MBeanServerFactory.getClassLoaderRepository(null).loadClass(refMBeanClassName);
279:
280:                // Checks if it is a MBean class
281:                // Can throw NotCompliantMBeanException
282:
283:                //    MBeanIntrospectorSupport.getInstance().checkCompliance(refMBeanClass);
284:
285:                this.refMBeanClassName = refMBeanClassName;
286:
287:            }
288:
289:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.