Source Code Cross Referenced for RoleInfo.java in  » EJB-Server-JBoss-4.2.1 » jmx » 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 » EJB Server JBoss 4.2.1 » jmx » javax.management.relation 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source.
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004:         * as indicated by the @author tags. See the copyright.txt file in the
005:         * distribution for a full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package javax.management.relation;
023:
024:        import org.jboss.mx.util.Serialization;
025:
026:        import javax.management.NotCompliantMBeanException;
027:        import java.io.IOException;
028:        import java.io.ObjectInputStream;
029:        import java.io.ObjectOutputStream;
030:        import java.io.ObjectStreamField;
031:        import java.io.Serializable;
032:
033:        /**
034:         * This class contains information about a role. For example the
035:         * number of mbean class name of the role, how many mbeans
036:         * are part of the role, whether the role is read/write, etc.<p>
037:         *
038:         * @author  <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
039:         * @author  <a href="mailto:thomas.diesler@jboss.com">Thomas Diesler</a>.
040:         *
041:         * @version $Revision: 57200 $
042:         */
043:        public class RoleInfo implements  Serializable {
044:            // Constants ---------------------------------------------------
045:
046:            /**
047:             * A value used to specify an infinite number of mbeans are allowed
048:             * in the role
049:             */
050:            public static int ROLE_CARDINALITY_INFINITY = -1;
051:
052:            // Attributes --------------------------------------------------
053:
054:            /**
055:             * The name of the role.
056:             */
057:            private String name;
058:
059:            /**
060:             * The className of the MBeans in the role.
061:             */
062:            private String referencedMBeanClassName;
063:
064:            /**
065:             * The readable attribute of the role.
066:             */
067:            boolean isReadable;
068:
069:            /**
070:             * The writable attribute of the role.
071:             */
072:            boolean isWritable;
073:
074:            /**
075:             * The minimum degree of the role.
076:             */
077:            int minDegree;
078:
079:            /**
080:             * The maximum degree of the role.
081:             */
082:            int maxDegree;
083:
084:            /**
085:             * The description of the role
086:             */
087:            String description;
088:
089:            // Static ------------------------------------------------------
090:
091:            private static final long serialVersionUID;
092:            private static final ObjectStreamField[] serialPersistentFields;
093:
094:            static {
095:                switch (Serialization.version) {
096:                case Serialization.V1R0:
097:                    serialVersionUID = 7227256952085334351L;
098:                    serialPersistentFields = new ObjectStreamField[] {
099:                            new ObjectStreamField("myDescription", String.class),
100:                            new ObjectStreamField("myIsReadableFlg",
101:                                    Boolean.TYPE),
102:                            new ObjectStreamField("myIsWritableFlg",
103:                                    Boolean.TYPE),
104:                            new ObjectStreamField("myMaxDegree", Integer.TYPE),
105:                            new ObjectStreamField("myMinDegree", Integer.TYPE),
106:                            new ObjectStreamField("myName", String.class),
107:                            new ObjectStreamField("myRefMBeanClassName",
108:                                    String.class) };
109:                    break;
110:                default:
111:                    serialVersionUID = 2504952983494636987L;
112:                    serialPersistentFields = new ObjectStreamField[] {
113:                            new ObjectStreamField("description", String.class),
114:                            new ObjectStreamField("isReadable", Boolean.TYPE),
115:                            new ObjectStreamField("isWritable", Boolean.TYPE),
116:                            new ObjectStreamField("maxDegree", Integer.TYPE),
117:                            new ObjectStreamField("minDegree", Integer.TYPE),
118:                            new ObjectStreamField("name", String.class),
119:                            new ObjectStreamField("referencedMBeanClassName",
120:                                    String.class) };
121:                }
122:            }
123:
124:            // Constructors ------------------------------------------------
125:
126:            /**
127:             * Copies the role info.
128:             *
129:             * @param other the role to copy.
130:             * @exception IllegalArgumentException for a null value.
131:             */
132:            public RoleInfo(RoleInfo other) throws IllegalArgumentException {
133:                if (other == null)
134:                    throw new IllegalArgumentException("Null role info");
135:                this .name = other.name;
136:                this .referencedMBeanClassName = other.referencedMBeanClassName;
137:                this .isReadable = other.isReadable;
138:                this .isWritable = other.isWritable;
139:                this .minDegree = other.minDegree;
140:                this .maxDegree = other.maxDegree;
141:                this .description = other.description;
142:            }
143:
144:            /**
145:             * Construct a role info with the given name and class name.
146:             * It is set to read/writable with a minimum and maximum degree of 1.
147:             * The description is null.
148:             *
149:             * @param name the name of the role.
150:             * @param className the name of the MBean class.
151:             * @exception IllegalArgumentException for a null value.
152:             * @exception ClassNotFoundException when the className does not exist.
153:             * @exception NotCompliantMBeanException when the className is not an
154:             *            mbean class.
155:             */
156:            public RoleInfo(String name, String className)
157:                    throws IllegalArgumentException, ClassNotFoundException,
158:                    NotCompliantMBeanException {
159:                this (name, className, true, true);
160:            }
161:
162:            /**
163:             * Construct a role info with the given name, class name and
164:             * read/write attributes. It has a minimum and maximum degree of 1.
165:             * The description is null.
166:             *
167:             * @param name the name of the role.
168:             * @param className the name of the MBean class.
169:             * @param readable true for readable, false otherwise.
170:             * @param writable true for writable, false otherwise.
171:             * @exception IllegalArgumentException for a null value.
172:             * @exception ClassNotFoundException when the className does not exist.
173:             * @exception NotCompliantMBeanException when the className is not an
174:             *            mbean class.
175:             */
176:            public RoleInfo(String name, String className, boolean readable,
177:                    boolean writable) throws IllegalArgumentException,
178:                    ClassNotFoundException, NotCompliantMBeanException {
179:                if (name == null)
180:                    throw new IllegalArgumentException("Null name");
181:                if (className == null)
182:                    throw new IllegalArgumentException("Null class name");
183:                this .name = name;
184:                this .referencedMBeanClassName = className;
185:                this .isReadable = readable;
186:                this .isWritable = writable;
187:                minDegree = 1;
188:                maxDegree = 1;
189:            }
190:
191:            /**
192:             * Construct a role info with the given name, class name,
193:             * read/write attributes, minimum/maximum degree and description.
194:             * The description can be null.<p>
195:             *
196:             * Pass <i>ROLE_CARDINALITY_INFINITY</i> for an unlimited degree.
197:             * The minimum must be less than or equal to the maximum.
198:             *
199:             * @param name the name of the role.
200:             * @param className the name of the MBean class.
201:             * @param readable true for readable, false otherwise.
202:             * @param writable true for writable, false otherwise.
203:             * @param minDegree the minimum degree.
204:             * @param maxDegree the maximum degree.
205:             * @param description the description.
206:             * @exception IllegalArgumentException for a null value.
207:             * @exception ClassNotFoundException when the className does not exist.
208:             * @exception NotCompliantMBeanException when the className is not an
209:             *            mbean class.
210:             * @exception InvalidRoleInfoException when the minimum degree is
211:             *            greater than the maximum.
212:             */
213:            public RoleInfo(String name, String className, boolean readable,
214:                    boolean writable, int minDegree, int maxDegree,
215:                    String description) throws IllegalArgumentException,
216:                    ClassNotFoundException, NotCompliantMBeanException,
217:                    InvalidRoleInfoException {
218:                if (name == null)
219:                    throw new IllegalArgumentException("Null name");
220:                if (className == null)
221:                    throw new IllegalArgumentException("Null class name");
222:
223:                if (minDegree < ROLE_CARDINALITY_INFINITY)
224:                    throw new InvalidRoleInfoException("invalid minimum");
225:                if (maxDegree < ROLE_CARDINALITY_INFINITY)
226:                    throw new InvalidRoleInfoException("invalid maximum");
227:                if (maxDegree < minDegree
228:                        && maxDegree != ROLE_CARDINALITY_INFINITY)
229:                    throw new InvalidRoleInfoException(
230:                            "maximum less than minimum");
231:                if (minDegree == ROLE_CARDINALITY_INFINITY
232:                        && maxDegree != ROLE_CARDINALITY_INFINITY)
233:                    throw new InvalidRoleInfoException(
234:                            "maximum less than minimum");
235:
236:                this .name = name;
237:                this .referencedMBeanClassName = className;
238:                this .minDegree = minDegree;
239:                this .maxDegree = maxDegree;
240:                this .isReadable = readable;
241:                this .isWritable = writable;
242:                this .description = description;
243:            }
244:
245:            // Public ------------------------------------------------------
246:
247:            /**
248:             * Check to see whether a given value is greater than or equal to the
249:             * minimum degree.
250:             *
251:             * @param value the value to check.
252:             * @return true when it is greater than or equal to the minimum degree,
253:             *         false otherwise.
254:             */
255:            public boolean checkMinDegree(int value) {
256:                if (minDegree == ROLE_CARDINALITY_INFINITY)
257:                    return value >= ROLE_CARDINALITY_INFINITY;
258:                else
259:                    return value >= minDegree;
260:            }
261:
262:            /**
263:             * Check to see whether a given value is less than or equal to the
264:             * maximum degree.
265:             *
266:             * @param value the value to check.
267:             * @return true when it is less than or equal to the maximum degree,
268:             *         false otherwise.
269:             */
270:            public boolean checkMaxDegree(int value) {
271:                if (maxDegree == ROLE_CARDINALITY_INFINITY)
272:                    return maxDegree >= ROLE_CARDINALITY_INFINITY;
273:                else
274:                    return value <= maxDegree;
275:            }
276:
277:            /**
278:             * Retrieve the description of the role.
279:             *
280:             * @return the description
281:             */
282:            public String getDescription() {
283:                return description;
284:            }
285:
286:            /**
287:             * Retrieve the minimum degree.
288:             *
289:             * @return the minimum degree
290:             */
291:            public int getMinDegree() {
292:                return minDegree;
293:            }
294:
295:            /**
296:             * Retrieve the maximum degree.
297:             *
298:             * @return the maximum degree
299:             */
300:            public int getMaxDegree() {
301:                return maxDegree;
302:            }
303:
304:            /**
305:             * Retrieve the name of the role.
306:             *
307:             * @return the name
308:             */
309:            public String getName() {
310:                return name;
311:            }
312:
313:            /**
314:             * Retrieve the class name of MBeans in this role.
315:             *
316:             * @return the class name
317:             */
318:            public String getRefMBeanClassName() {
319:                return referencedMBeanClassName;
320:            }
321:
322:            /**
323:             * Retrieve the readable attribute.
324:             *
325:             * @return true for readable, false otherwise
326:             */
327:            public boolean isReadable() {
328:                return isReadable;
329:            }
330:
331:            /**
332:             * Retrieve the writable attribute.
333:             *
334:             * @return true for writable, false otherwise
335:             */
336:            public boolean isWritable() {
337:                return isWritable;
338:            }
339:
340:            // Object Overrides --------------------------------------------
341:
342:            /**
343:             * Retrieve a string description of the role info.
344:             */
345:            public String toString() {
346:                StringBuffer buffer = new StringBuffer("RoleInfo for name: (");
347:                buffer.append(name);
348:                buffer.append(") class name: (");
349:                buffer.append(referencedMBeanClassName);
350:                buffer.append(") description: (");
351:                buffer.append(description);
352:                buffer.append(") readable: (");
353:                buffer.append(isReadable);
354:                buffer.append(") writable: (");
355:                buffer.append(isWritable);
356:                buffer.append(") minimum degree: (");
357:                buffer.append(minDegree);
358:                buffer.append(") maximum degree: (");
359:                buffer.append(maxDegree);
360:                buffer.append(")");
361:                return buffer.toString();
362:            }
363:
364:            // Private -----------------------------------------------------
365:
366:            private void readObject(ObjectInputStream ois) throws IOException,
367:                    ClassNotFoundException {
368:                switch (Serialization.version) {
369:                case Serialization.V1R0:
370:                    ObjectInputStream.GetField getField = ois.readFields();
371:                    description = (String) getField.get("myDescription", null);
372:                    isReadable = getField.get("myIsReadableFlg", false);
373:                    isWritable = getField.get("myIsWritableFlg", false);
374:                    maxDegree = getField.get("myMaxDegree", 1);
375:                    minDegree = getField.get("myMinDegree", 1);
376:                    name = (String) getField.get("myName", null);
377:                    referencedMBeanClassName = (String) getField.get(
378:                            "myRefMBeanClassName", null);
379:                    break;
380:                default:
381:                    ois.defaultReadObject();
382:                }
383:            }
384:
385:            private void writeObject(ObjectOutputStream oos) throws IOException {
386:                switch (Serialization.version) {
387:                case Serialization.V1R0:
388:                    ObjectOutputStream.PutField putField = oos.putFields();
389:                    putField.put("myDescription", description);
390:                    putField.put("myIsReadableFlg", isReadable);
391:                    putField.put("myIsWritableFlg", isWritable);
392:                    putField.put("myMaxDegree", maxDegree);
393:                    putField.put("myMinDegree", minDegree);
394:                    putField.put("myName", name);
395:                    putField.put("myRefMBeanClassName",
396:                            referencedMBeanClassName);
397:                    oos.writeFields();
398:                    break;
399:                default:
400:                    oos.defaultWriteObject();
401:                }
402:            }
403:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.