Source Code Cross Referenced for RelationNotification.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.util.ArrayList;
029:        import java.util.List;
030:
031:        import javax.management.Notification;
032:        import javax.management.ObjectName;
033:
034:        import org.jboss.mx.util.Serialization;
035:
036:        /**
037:         * A notification from the relation service.
038:         *
039:         * @author <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>
040:         * @version $Revision: 57200 $
041:         *
042:         * <p><b>Revisions:</b>
043:         * <p><b>20020715 Adrian Brock:</b>
044:         * <ul>
045:         * <li> Serialization
046:         * </ul>
047:         */
048:        public class RelationNotification extends Notification {
049:            // Constants -----------------------------------------------------
050:
051:            /**
052:             * Creation of an internal relation.
053:             */
054:            public static final String RELATION_BASIC_CREATION = "jmx.relation.creation.basic";
055:
056:            /**
057:             * Removal of an internal relation.
058:             */
059:            public static final String RELATION_BASIC_REMOVAL = "jmx.relation.removal.basic";
060:
061:            /**
062:             * Update of an internal relation.
063:             */
064:            public static final String RELATION_BASIC_UPDATE = "jmx.relation.update.basic";
065:
066:            /**
067:             * Creation of MBean relation added to the relation service.
068:             */
069:            public static final String RELATION_MBEAN_CREATION = "jmx.relation.creation.mbean";
070:
071:            /**
072:             * Removal of MBean relation added to the relation service.
073:             */
074:            public static final String RELATION_MBEAN_REMOVAL = "jmx.relation.removal.mbean";
075:
076:            /**
077:             * Update of MBean relation added to the relation service.
078:             */
079:            public static final String RELATION_MBEAN_UPDATE = "jmx.relation.update.mbean";
080:
081:            /**
082:             * Tag used to identify creation/removal constructor used.
083:             */
084:            private static int CREATION_REMOVAL = 0;
085:
086:            /**
087:             * Tag used to identify update constructor used.
088:             */
089:            private static int UPDATE = 1;
090:
091:            // Attributes ----------------------------------------------------
092:
093:            /**
094:             * The MBeans removed when a relation type is removed.
095:             */
096:            private List unregisterMBeanList;
097:
098:            /**
099:             * The new list of object names in the role.
100:             */
101:            private List newRoleValue;
102:
103:            /**
104:             * The relation's object name.
105:             */
106:            private ObjectName relationObjName;
107:
108:            /**
109:             * The old list of object names in the role.
110:             */
111:            private List oldRoleValue;
112:
113:            /**
114:             * The relation id of this notification.
115:             */
116:            private String relationId;
117:
118:            /**
119:             * The relation type name of this notification.
120:             */
121:            private String relationTypeName;
122:
123:            /**
124:             * The role name of an updated role, only for role updates.
125:             */
126:            private String roleName;
127:
128:            // Static --------------------------------------------------------
129:
130:            private static final long serialVersionUID;
131:            private static final ObjectStreamField[] serialPersistentFields;
132:
133:            static {
134:                switch (Serialization.version) {
135:                case Serialization.V1R0:
136:                    serialVersionUID = -2126464566505527147L;
137:                    serialPersistentFields = new ObjectStreamField[] {
138:                            new ObjectStreamField("myNewRoleValue",
139:                                    ArrayList.class),
140:                            new ObjectStreamField("myOldRoleValue",
141:                                    ArrayList.class),
142:                            new ObjectStreamField("myRelId", String.class),
143:                            new ObjectStreamField("myRelObjName",
144:                                    ObjectName.class),
145:                            new ObjectStreamField("myRelTypeName", String.class),
146:                            new ObjectStreamField("myRoleName", String.class),
147:                            new ObjectStreamField("myUnregMBeanList",
148:                                    ArrayList.class) };
149:                    break;
150:                default:
151:                    serialVersionUID = -6871117877523310399L;
152:                    serialPersistentFields = new ObjectStreamField[] {
153:                            new ObjectStreamField("newRoleValue", List.class),
154:                            new ObjectStreamField("oldRoleValue", List.class),
155:                            new ObjectStreamField("relationId", String.class),
156:                            new ObjectStreamField("relationObjName",
157:                                    ObjectName.class),
158:                            new ObjectStreamField("relationTypeName",
159:                                    String.class),
160:                            new ObjectStreamField("roleName", String.class),
161:                            new ObjectStreamField("unregisterMBeanList",
162:                                    List.class), };
163:                }
164:            }
165:
166:            // Constructors --------------------------------------------------
167:
168:            /**
169:             * Construct a new relation notification for a creation or removal.<p>
170:             *
171:             * The notification type should be one {@link #RELATION_BASIC_CREATION},
172:             * {@link #RELATION_BASIC_REMOVAL}, {@link #RELATION_MBEAN_CREATION} or
173:             * {@link #RELATION_MBEAN_REMOVAL}.<p>
174:             *
175:             * The relation type cannot be null, the source cannot be null and it
176:             * must be a relation service, the relation id cannot be null, the
177:             * relation type name cannot null.
178:             *
179:             * @param type the notification type.
180:             * @param source the object sending the notification (always the
181:             *        the relation service).
182:             * @param sequenceNumber the number identifying the notification
183:             * @param timeStamp the time of the notification
184:             * @param message human readable string
185:             * @param relationId the relation id
186:             * @param relTypeName the relation type name
187:             * @param relObjName the relation MBean object name (null
188:             *        for internal relations)
189:             * @param unregMBeans the list of object names of mbeans to be
190:             *        unregistered from the relation service because of a relation
191:             *        removal. Only relevant for removals, can be null.
192:             * @exception IllegalArgumentException for null or invalid parameters.
193:             */
194:            public RelationNotification(String type, Object source,
195:                    long sequenceNumber, long timeStamp, String message,
196:                    String relationId, String relTypeName,
197:                    ObjectName relObjName, List unregMBeans)
198:                    throws IllegalArgumentException {
199:                super (type, source, sequenceNumber, timeStamp, message);
200:                init(CREATION_REMOVAL, type, source, sequenceNumber, timeStamp,
201:                        message, relationId, relTypeName, relObjName,
202:                        unregMBeans, null, null, null);
203:            }
204:
205:            /**
206:             * Construct a new relation notification for an update.<p>
207:             *
208:             * The notification type should be one {@link #RELATION_BASIC_UPDATE},
209:             * {@link #RELATION_MBEAN_UPDATE}
210:             *
211:             * The relation type cannot be null, the source cannot be null and it
212:             * must be a relation service, the relation id cannot be null, the
213:             * relation type name cannot null.
214:             *
215:             * @param type the notification type.
216:             * @param source the object sending the notification (always the
217:             *        the relation service).
218:             * @param sequenceNumber the number identifying the notification
219:             * @param timeStamp the time of the notification
220:             * @param message human readable string
221:             * @param relationId the relation id
222:             * @param relTypeName the relation type name
223:             * @param relObjName the relation MBean object name (null
224:             *        for internal relations)
225:             * @param roleName the role name
226:             * @param newRoleValue the new value of the role
227:             * @param newRoleValue the old value of the role
228:             * @exception IllegalArgumentException for null or invalid parameters.
229:             */
230:            public RelationNotification(String type, Object source,
231:                    long sequenceNumber, long timeStamp, String message,
232:                    String relationId, String relTypeName,
233:                    ObjectName relObjName, String roleName, List newRoleValue,
234:                    List oldRoleValue) throws IllegalArgumentException {
235:                super (type, source, sequenceNumber, timeStamp, message);
236:                init(UPDATE, type, source, sequenceNumber, timeStamp, message,
237:                        relationId, relTypeName, relObjName, null, roleName,
238:                        newRoleValue, oldRoleValue);
239:            }
240:
241:            // Public --------------------------------------------------------
242:
243:            /**
244:             * Retrieves a list of Object names of the mbeans that will be removed
245:             * from the relation service because of a relation's removal. This
246:             * is only relevant for relation removal events.
247:             *
248:             * @return the list of removed mbeans.
249:             */
250:            public List getMBeansToUnregister() {
251:                if (unregisterMBeanList == null)
252:                    return new ArrayList();
253:                else
254:                    return new ArrayList(unregisterMBeanList);
255:            }
256:
257:            /**
258:             * Retrieves the new list of object names in the role.
259:             *
260:             * @return the new list.
261:             */
262:            public List getNewRoleValue() {
263:                if (newRoleValue == null)
264:                    return new ArrayList();
265:                else
266:                    return new ArrayList(newRoleValue);
267:            }
268:
269:            /**
270:             * Retrieves the object name of the mbean (null for an internal relation).
271:             *
272:             * @return the relation's object name.
273:             */
274:            public ObjectName getObjectName() {
275:                return relationObjName;
276:            }
277:
278:            /**
279:             * Retrieves the old list of object names in the role.
280:             *
281:             * @return the old list.
282:             */
283:            public List getOldRoleValue() {
284:                if (oldRoleValue == null)
285:                    return new ArrayList();
286:                else
287:                    return new ArrayList(oldRoleValue);
288:            }
289:
290:            /**
291:             * Retrieves the relation id of this notification.
292:             *
293:             * @return the relation id.
294:             */
295:            public String getRelationId() {
296:                return relationId;
297:            }
298:
299:            /**
300:             * Retrieves the relation type name of this notification.
301:             *
302:             * @return the relation type name.
303:             */
304:            public String getRelationTypeName() {
305:                return relationTypeName;
306:            }
307:
308:            /**
309:             * Retrieves the role name of an updated role, only for role updates.
310:             *
311:             * @return the name of the updated role.
312:             */
313:            public String getRoleName() {
314:                return roleName;
315:            }
316:
317:            // Notification overrides ----------------------------------------
318:
319:            // Package protected ---------------------------------------------
320:
321:            // Protected -----------------------------------------------------
322:
323:            // Private -------------------------------------------------------
324:
325:            /**
326:             * Does most the work for the constructors, see the contructors
327:             * for details.<p>
328:             *
329:             * @param which the constructor called.
330:             * @param type the notification type.
331:             * @param source the object sending the notification (always the
332:             *        the relation service).
333:             * @param sequenceNumber the number identifying the notification
334:             * @param timeStamp the time of the notification
335:             * @param message human readable string
336:             * @param relationId the relation id
337:             * @param relTypeName the relation type name
338:             * @param relObjName the relation MBean object name (null
339:             *        for internal relations)
340:             * @param unregMBeans the mbeans unregistered when a relation is removed.
341:             * @param roleName the role name
342:             * @param newRoleValue the new value of the role
343:             * @param newRoleValue the old value of the role
344:             * @exception IllegalArgumentException for null or invalid parameters.
345:             */
346:            private void init(int which, String type, Object source,
347:                    long sequenceNumber, long timeStamp, String message,
348:                    String relationId, String relTypeName,
349:                    ObjectName relObjName, List unregMBeans, String roleName,
350:                    List newRoleValue, List oldRoleValue)
351:                    throws IllegalArgumentException {
352:                // Invalid notification type
353:                if (type == null)
354:                    throw new IllegalArgumentException("null notification type");
355:                if (which == CREATION_REMOVAL
356:                        && type != RELATION_BASIC_CREATION
357:                        && type != RELATION_BASIC_REMOVAL
358:                        && type != RELATION_MBEAN_CREATION
359:                        && type != RELATION_MBEAN_REMOVAL)
360:                    throw new IllegalArgumentException(
361:                            "Invalid creation/removal notifcation");
362:                if (which == UPDATE && type != RELATION_BASIC_UPDATE
363:                        && type != RELATION_MBEAN_UPDATE)
364:                    throw new IllegalArgumentException(
365:                            "Invalid update notifcation");
366:
367:                // Source must be a Relation Service
368:                if (type == null)
369:                    throw new IllegalArgumentException("null source");
370:
371:                // REVIEW: According to the spec, this should be a RelationService
372:                // that doesn't make any sense, it's not serializable
373:                // I use the object name
374:                //if ((source instanceof RelationService) == false)
375:                //  throw new IllegalArgumentException("Source not a relation service");
376:
377:                // Relation id
378:                if (relationId == null)
379:                    throw new IllegalArgumentException("null relation id");
380:
381:                // Relation type name
382:                if (relTypeName == null)
383:                    throw new IllegalArgumentException(
384:                            "null relation type name");
385:
386:                // Role Info
387:                if (which == UPDATE && roleName == null)
388:                    throw new IllegalArgumentException("null role name");
389:
390:                // New role value
391:                if (which == UPDATE && newRoleValue == null)
392:                    throw new IllegalArgumentException("null new role value");
393:
394:                // Old role value
395:                if (which == UPDATE && oldRoleValue == null)
396:                    throw new IllegalArgumentException("null old role value");
397:
398:                this .relationId = relationId;
399:                this .relationTypeName = relTypeName;
400:                this .relationObjName = relObjName;
401:                if (unregMBeans != null)
402:                    this .unregisterMBeanList = new ArrayList(unregMBeans);
403:                if (roleName != null)
404:                    this .roleName = roleName;
405:                if (newRoleValue != null)
406:                    this .newRoleValue = new ArrayList(newRoleValue);
407:                if (oldRoleValue != null)
408:                    this .oldRoleValue = new ArrayList(oldRoleValue);
409:            }
410:
411:            private void readObject(ObjectInputStream ois) throws IOException,
412:                    ClassNotFoundException {
413:                switch (Serialization.version) {
414:                case Serialization.V1R0:
415:                    ObjectInputStream.GetField getField = ois.readFields();
416:                    newRoleValue = (ArrayList) getField.get("myNewRoleValue",
417:                            null);
418:                    oldRoleValue = (ArrayList) getField.get("myOldRoleValue",
419:                            null);
420:                    relationId = (String) getField.get("myRelId", null);
421:                    relationObjName = (ObjectName) getField.get("myRelObjName",
422:                            null);
423:                    relationTypeName = (String) getField.get("myRelTypeName",
424:                            null);
425:                    roleName = (String) getField.get("myRoleName", null);
426:                    unregisterMBeanList = (ArrayList) getField.get(
427:                            "myUnregMBeanList", null);
428:                    break;
429:                default:
430:                    ois.defaultReadObject();
431:                }
432:            }
433:
434:            private void writeObject(ObjectOutputStream oos) throws IOException {
435:                switch (Serialization.version) {
436:                case Serialization.V1R0:
437:                    ObjectOutputStream.PutField putField = oos.putFields();
438:                    putField.put("myNewRoleValue", newRoleValue);
439:                    putField.put("myOldRoleValue", oldRoleValue);
440:                    putField.put("myRelId", relationId);
441:                    putField.put("myRelObjName", relationObjName);
442:                    putField.put("myRelTypeName", relationTypeName);
443:                    putField.put("myRoleName", roleName);
444:                    putField.put("myUnregMBeanList", unregisterMBeanList);
445:                    oos.writeFields();
446:                    break;
447:                default:
448:                    oos.defaultWriteObject();
449:                }
450:            }
451:
452:            // Inner classes -------------------------------------------------
453:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.