Source Code Cross Referenced for Role.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 java.io.IOException;
025:        import java.io.ObjectInputStream;
026:        import java.io.ObjectOutputStream;
027:        import java.io.ObjectStreamField;
028:        import java.io.Serializable;
029:
030:        import java.util.ArrayList;
031:        import java.util.Iterator;
032:        import java.util.List;
033:
034:        import org.jboss.mx.util.Serialization;
035:
036:        /**
037:         * A role is a role name and an ordered list of object names to
038:         * the MBeans in the role.
039:         *
040:         * @author <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>
041:         * @version $Revision: 57200 $
042:         *
043:         * <p><b>Revisions:</b>
044:         * <p><b>20020716 Adrian Brock:</b>
045:         * <ul>
046:         * <li> Serialization
047:         * </ul>
048:         */
049:        public class Role implements  Serializable {
050:            // Attributes ----------------------------------------------------
051:
052:            /**
053:             * The role name
054:             */
055:            private String name;
056:
057:            /**
058:             * An ordered list of MBean object names.
059:             */
060:            private List objectNameList;
061:
062:            // Static --------------------------------------------------------
063:
064:            private static final long serialVersionUID;
065:            private static final ObjectStreamField[] serialPersistentFields;
066:
067:            static {
068:                switch (Serialization.version) {
069:                case Serialization.V1R0:
070:                    serialVersionUID = -1959486389343113026L;
071:                    serialPersistentFields = new ObjectStreamField[] {
072:                            new ObjectStreamField("myName", String.class),
073:                            new ObjectStreamField("myObjNameList", List.class) };
074:                    break;
075:                default:
076:                    serialVersionUID = -279985518429862552L;
077:                    serialPersistentFields = new ObjectStreamField[] {
078:                            new ObjectStreamField("name", String.class),
079:                            new ObjectStreamField("objectNameList", List.class) };
080:                }
081:            }
082:
083:            /**
084:             * Formats the role value for output.<p>
085:             *
086:             * The spec says it should be a comma separated list of object names.
087:             * But the RI uses new lines which makes more sense for object names.
088:             *
089:             * @param roleValue the role value to print
090:             * @return the string representation
091:             * @exception IllegalArgumentException for null value.
092:             */
093:            public static String roleValueToString(List roleValue)
094:                    throws IllegalArgumentException {
095:                if (roleValue == null)
096:                    throw new IllegalArgumentException("null roleValue");
097:                StringBuffer buffer = new StringBuffer();
098:                Iterator iterator = roleValue.iterator();
099:                while (iterator.hasNext()) {
100:                    buffer.append(iterator.next());
101:                    if (iterator.hasNext())
102:                        buffer.append("\n");
103:                }
104:                return buffer.toString();
105:            }
106:
107:            // Constructors --------------------------------------------------
108:
109:            /**
110:             * Construct a new role.<p>
111:             *
112:             * No validation is performed until the role is set of in a
113:             * relation. Passed parameters must not be null.<p>
114:             * 
115:             * The passed list must be an ArrayList.
116:             *
117:             * @param roleName the role name
118:             * @param roleValue the MBean object names in the role
119:             * @exception IllegalArgumentException for null values.
120:             */
121:            public Role(String roleName, List roleValue)
122:                    throws IllegalArgumentException {
123:                setRoleName(roleName);
124:                setRoleValue(roleValue);
125:            }
126:
127:            // Public ---------------------------------------------------------
128:
129:            /**
130:             * Retrieve the role name.
131:             * 
132:             * @return the role name.
133:             */
134:            public String getRoleName() {
135:                return name;
136:            }
137:
138:            /**
139:             * Retrieve the role value.
140:             * 
141:             * @return a list of MBean object names.
142:             */
143:            public List getRoleValue() {
144:                return new ArrayList(objectNameList);
145:            }
146:
147:            /**
148:             * Set the role name.
149:             * 
150:             * @param roleName the role name.
151:             * @exception IllegalArgumentException for a null value
152:             */
153:            public void setRoleName(String roleName)
154:                    throws IllegalArgumentException {
155:                if (roleName == null)
156:                    throw new IllegalArgumentException("Null roleName");
157:                name = roleName;
158:            }
159:
160:            /**
161:             * Set the role value it must be an ArrayList.
162:             * A list of mbean object names.
163:             * 
164:             * @param roleValue the role value.
165:             * @exception IllegalArgumentException for a null value or not an
166:             *            array list
167:             */
168:            public void setRoleValue(List roleValue)
169:                    throws IllegalArgumentException {
170:                if (roleValue == null)
171:                    throw new IllegalArgumentException("Null roleValue");
172:                objectNameList = new ArrayList(roleValue);
173:            }
174:
175:            // Object Overrides -------------------------------------------------
176:
177:            /**
178:             * Clones the object.
179:             *
180:             * @todo fix this not to use the copy constructor
181:             *
182:             * @return a copy of the role
183:             * @throws CloneNotSupportedException
184:             */
185:            public synchronized Object clone() {
186:                return new Role(name, objectNameList);
187:                /*      try
188:                 {
189:                 Role clone = (Role) super.clone();
190:                 clone.name = this.name;
191:                 clone.objectNameList = new ArrayList(this.objectNameList);
192:                 return clone;
193:                 }
194:                 catch (CloneNotSupportedException e)
195:                 {
196:                 throw new RuntimeException(e.toString());
197:                 }
198:                 */}
199:
200:            /**
201:             * Formats the role for output.
202:             *
203:             * @return a human readable string
204:             */
205:            public synchronized String toString() {
206:                StringBuffer buffer = new StringBuffer();
207:                buffer.append("Role@");
208:                buffer.append(System.identityHashCode(this ));
209:                buffer.append(" RoleName(");
210:                buffer.append(name);
211:                buffer.append(") ObjectNames (");
212:                Iterator iterator = objectNameList.iterator();
213:                while (iterator.hasNext()) {
214:                    buffer.append(iterator.next());
215:                    if (iterator.hasNext())
216:                        buffer.append(" & ");
217:                }
218:                buffer.append(")");
219:                return buffer.toString();
220:            }
221:
222:            // Private -----------------------------------------------------
223:
224:            private void readObject(ObjectInputStream ois) throws IOException,
225:                    ClassNotFoundException {
226:                switch (Serialization.version) {
227:                case Serialization.V1R0:
228:                    ObjectInputStream.GetField getField = ois.readFields();
229:                    name = (String) getField.get("myName", null);
230:                    objectNameList = (List) getField.get("myObjNameList", null);
231:                    break;
232:                default:
233:                    ois.defaultReadObject();
234:                }
235:            }
236:
237:            private void writeObject(ObjectOutputStream oos) throws IOException {
238:                switch (Serialization.version) {
239:                case Serialization.V1R0:
240:                    ObjectOutputStream.PutField putField = oos.putFields();
241:                    putField.put("myName", name);
242:                    putField.put("myObjNameList", objectNameList);
243:                    oos.writeFields();
244:                    break;
245:                default:
246:                    oos.defaultWriteObject();
247:                }
248:            }
249:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.