Source Code Cross Referenced for RelationNotification.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.util.ArrayList;
011:        import java.util.List;
012:        import javax.management.Notification;
013:        import javax.management.ObjectName;
014:
015:        /**
016:         * A RelationNotification notification is sent when a relation is created via
017:         * the Relation Service, or a MBean is added as a relation in the Relation
018:         * Service, or a role is updated in a relation, or a relation is removed from
019:         * the Relation Service
020:         *
021:         * @author <a href="mailto:young_yy@hotmail.org">Young Yang</a>
022:         */
023:
024:        public class RelationNotification extends Notification {
025:
026:            //
027:            // Notification types
028:            //
029:
030:            /**
031:             * Type for the creation of an internal relation
032:             */
033:            public static final String RELATION_BASIC_CREATION = "jmx.relation.creation.basic";
034:            /**
035:             * Type for the relation MBean added into the Relation Service
036:             */
037:            public static final String RELATION_MBEAN_CREATION = "jmx.relation.creation.mbean";
038:            /**
039:             * Type for an update of an internal relation
040:             */
041:            public static final String RELATION_BASIC_UPDATE = "jmx.relation.update.basic";
042:            /**
043:             * Type for the update of a relation MBean
044:             */
045:            public static final String RELATION_MBEAN_UPDATE = "jmx.relation.update.mbean";
046:            /**
047:             * Type for the removal from the Relation Service of an internal relation
048:             */
049:            public static final String RELATION_BASIC_REMOVAL = "jmx.relation.removal.basic";
050:            /**
051:             * Type for the removal from the Relation Service of a relation MBean
052:             */
053:            public static final String RELATION_MBEAN_REMOVAL = "jmx.relation.removal.mbean";
054:
055:            //
056:            // Private members
057:            //
058:
059:            // Relation identifier of created/removed/updated relation
060:            private String myRelId = null;
061:
062:            // Relation type name of created/removed/updated relation
063:            private String myRelTypeName = null;
064:
065:            // ObjectName of the relation MBean of created/removed/updated relation
066:            // (only if the relation is represented by a MBean)
067:            private ObjectName myRelObjName = null;
068:
069:            // List of ObjectNames of referenced MBeans to be unregistered due to
070:            // relation removal
071:            private ArrayList myUnregMBeanList = null;
072:
073:            // Name of updated role (only for role update)
074:            private String myRoleName = null;
075:
076:            // Old role value (ArrayList of ObjectNames) (only for role update)
077:            private ArrayList myOldRoleValue = null;
078:
079:            // New role value (ArrayList of ObjectNames) (only for role update)
080:            private ArrayList myNewRoleValue = null;
081:
082:            //
083:            // Constructors
084:            //
085:
086:            /**
087:             * Creates a notification for either a relation creation (RelationSupport
088:             * object created internally in the Relation Service, or a MBean added as a
089:             * relation) or for a relation removal from the Relation Service
090:             *
091:             * @param theNtfType  type of the notification; either:
092:             * <P>- RELATION_BASIC_CREATION
093:             * <P>- RELATION_MBEAN_CREATION
094:             * <P>- RELATION_BASIC_REMOVAL
095:             * <P>- RELATION_MBEAN_REMOVAL
096:             * @param theSrcObj  source object, sending the notification. Will always
097:             * be a RelationService object.
098:             * @param TheSeqNbr  sequence number to identify the notification
099:             * @param theTimeStamp  time stamp
100:             * @param theMsg  human-readable message describing the notification
101:             * @param theRelId  relation id identifying the relation in the Relation
102:             * Service
103:             * @param theRelTypeName  name of the relation type
104:             * @param theRelObjName  ObjectName of the relation object if it is a MBean
105:             * (null for relations internally handled by the Relation Service)
106:             * @param theUnregMBeanList  list of ObjectNames of referenced MBeans
107:             * expected to be unregistered due to relation removal (only for removal,
108:             * due to CIM qualifiers, can be null)
109:             *
110:             * @exception IllegalArgumentException  if:
111:             * <P>- no value for the notification type
112:             * <P>- the notification type is not RELATION_BASIC_CREATION,
113:             * RELATION_MBEAN_CREATION, RELATION_BASIC_REMOVAL or
114:             * RELATION_MBEAN_REMOVAL
115:             * <P>- no source object
116:             * <P>- the source object is not a Relation Service
117:             * <P>- no relation id
118:             * <P>- no relation type name
119:             */
120:            public RelationNotification(String theNtfType, Object theSrcObj,
121:                    long TheSeqNbr, long theTimeStamp, String theMsg,
122:                    String theRelId, String theRelTypeName,
123:                    ObjectName theRelObjName, List theUnregMBeanList)
124:                    throws IllegalArgumentException {
125:
126:                super (theNtfType, theSrcObj, TheSeqNbr, theTimeStamp, theMsg);
127:
128:                // Can throw IllegalArgumentException
129:                initMembers(1, theNtfType, theSrcObj, TheSeqNbr, theTimeStamp,
130:                        theMsg, theRelId, theRelTypeName, theRelObjName,
131:                        theUnregMBeanList, null, null, null);
132:                return;
133:            }
134:
135:            /**
136:             * Creates a notification for a role update in a relation
137:             *
138:             * @param theNtfType  type of the notification; either:
139:             * <P>- RELATION_BASIC_UPDATE
140:             * <P>- RELATION_MBEAN_UPDATE
141:             * @param theSrcObj  source object, sending the notification. Will always
142:             * be a RelationService object.
143:             * @param TheSeqNbr  sequence number to identify the notification
144:             * @param theTimeStamp  time stamp
145:             * @param theMsg  human-readable message describing the notification
146:             * @param theRelId  relation id identifying the relation in the Relation
147:             * Service
148:             * @param theRelTypeName  name of the relation type
149:             * @param theRelObjName  ObjectName of the relation object if it is a MBean
150:             * (null for relations internally handled by the Relation Service)
151:             * @param theRoleName  name of the updated role
152:             * @param theNewRoleValue  new value (ArrayList of ObjectName objects)
153:             * @param theOldRoleValue  old value (ArrayList of ObjectName objects)
154:             *
155:             * @exception IllegalArgumentException  if null parameter
156:             */
157:            public RelationNotification(String theNtfType, Object theSrcObj,
158:                    long TheSeqNbr, long theTimeStamp, String theMsg,
159:                    String theRelId, String theRelTypeName,
160:                    ObjectName theRelObjName, String theRoleName,
161:                    List theNewRoleValue, List theOldRoleValue)
162:                    throws IllegalArgumentException {
163:
164:                super (theNtfType, theSrcObj, TheSeqNbr, theTimeStamp, theMsg);
165:
166:                // Can throw IllegalArgumentException
167:                initMembers(2, theNtfType, theSrcObj, TheSeqNbr, theTimeStamp,
168:                        theMsg, theRelId, theRelTypeName, theRelObjName, null,
169:                        theRoleName, theNewRoleValue, theOldRoleValue);
170:                return;
171:            }
172:
173:            //
174:            // Accessors
175:            //
176:
177:            /**
178:             * Returns the relation identifier of created/removed/updated relation
179:             */
180:            public String getRelationId() {
181:                return new String(myRelId);
182:            }
183:
184:            /**
185:             * Returns the relation type name of created/removed/updated relation
186:             */
187:            public String getRelationTypeName() {
188:                return new String(myRelTypeName);
189:            }
190:
191:            /**
192:             * Returns the ObjectName (if the relation is a MBean, else null) of the
193:             * created/removed/updated relation
194:             */
195:            public ObjectName getObjectName() {
196:                return myRelObjName;
197:            }
198:
199:            /**
200:             * Returns the list of ObjectNames of MBeans expected to be unregistered
201:             * due to a relation removal (only for relation removal)
202:             */
203:            public List getMBeansToUnregister() {
204:                ArrayList result = null;
205:                if (myUnregMBeanList != null) {
206:                    result = (ArrayList) (myUnregMBeanList.clone());
207:                } else {
208:                    result = new ArrayList();
209:                }
210:                return result;
211:            }
212:
213:            /**
214:             * Returns name of updated role of updated relation (only for role update)
215:             */
216:            public String getRoleName() {
217:                String result = null;
218:                if (myRoleName != null) {
219:                    result = new String(myRoleName);
220:                }
221:                return result;
222:            }
223:
224:            /**
225:             * Returns old value of updated role (only for role update)
226:             */
227:            public List getOldRoleValue() {
228:                ArrayList result = null;
229:                if (myOldRoleValue != null) {
230:                    result = (ArrayList) (myOldRoleValue.clone());
231:                } else {
232:                    result = new ArrayList();
233:                }
234:                return result;
235:            }
236:
237:            /**
238:             * Returns new value of updated role (only for role update)
239:             */
240:            public List getNewRoleValue() {
241:                ArrayList result = null;
242:                if (myNewRoleValue != null) {
243:                    result = (ArrayList) (myNewRoleValue.clone());
244:                } else {
245:                    result = new ArrayList();
246:                }
247:                return result;
248:            }
249:
250:            //
251:            // Misc
252:            //
253:
254:            // Initialises members
255:            //
256:            // -param theNtfKind  1 for creation/removal, 2 for update
257:            // -param theNtfType  type of the notification; either:
258:            //  - RELATION_BASIC_UPDATE
259:            //  - RELATION_MBEAN_UPDATE
260:            //  for an update, or:
261:            //  - RELATION_BASIC_CREATION
262:            //  - RELATION_MBEAN_CREATION
263:            //  - RELATION_BASIC_REMOVAL
264:            //  - RELATION_MBEAN_REMOVAL
265:            //  for a creation or removal
266:            // -param theSrcObj  source object, sending the notification. Will always
267:            //  be a RelationService object.
268:            // -param TheSeqNbr  sequence number to identify the notification
269:            // -param theTimeStamp  time stamp
270:            // -param theMsg  human-readable message describing the notification
271:            // -param theRelId  relation id identifying the relation in the Relation
272:            //  Service
273:            // -param theRelTypeName  name of the relation type
274:            // -param theRelObjName  ObjectName of the relation object if it is a MBean
275:            //  (null for relations internally handled by the Relation Service)
276:            // -param theUnregMBeanList  list of ObjectNames of MBeans expected to be
277:            //  removed due to relation removal
278:            // -param theRoleName  name of the updated role
279:            // -param theNewRoleValue  new value (ArrayList of ObjectName objects)
280:            // -param theOldRoleValue  old value (ArrayList of ObjectName objects)
281:            //
282:            // -exception IllegalArgumentException  if:
283:            //  - no value for the notification type
284:            //  - incorrect notification type
285:            //  - no source object
286:            //  - the source object is not a Relation Service
287:            //  - no relation id
288:            //  - no relation type name
289:            //  - no role name (for role update)
290:            //  - no role old value (for role update)
291:            //  - no role new value (for role update)
292:            private void initMembers(int theNtfKind, String theNtfType,
293:                    Object theSrcObj, long TheSeqNbr, long theTimeStamp,
294:                    String theMsg, String theRelId, String theRelTypeName,
295:                    ObjectName theRelObjName, List theUnregMBeanList,
296:                    String theRoleName, List theNewRoleValue,
297:                    List theOldRoleValue) throws IllegalArgumentException {
298:
299:                boolean badInitFlg = false;
300:
301:                if (theNtfType == null || theSrcObj == null
302:                        || (!(theSrcObj instanceof  RelationService))
303:                        || theRelId == null || theRelTypeName == null) {
304:
305:                    badInitFlg = true;
306:                }
307:
308:                if (theNtfKind == 1) {
309:
310:                    if ((!(theNtfType
311:                            .equals(RelationNotification.RELATION_BASIC_CREATION)))
312:                            && (!(theNtfType
313:                                    .equals(RelationNotification.RELATION_MBEAN_CREATION)))
314:                            && (!(theNtfType
315:                                    .equals(RelationNotification.RELATION_BASIC_REMOVAL)))
316:                            && (!(theNtfType
317:                                    .equals(RelationNotification.RELATION_MBEAN_REMOVAL)))) {
318:
319:                        // Creation/removal
320:                        badInitFlg = true;
321:                    }
322:
323:                } else if (theNtfKind == 2) {
324:
325:                    if (((!(theNtfType
326:                            .equals(RelationNotification.RELATION_BASIC_UPDATE))) && (!(theNtfType
327:                            .equals(RelationNotification.RELATION_MBEAN_UPDATE))))
328:                            || theRoleName == null
329:                            || theOldRoleValue == null
330:                            || theNewRoleValue == null) {
331:
332:                        // Role update
333:                        badInitFlg = true;
334:                    }
335:                }
336:
337:                if (badInitFlg) {
338:                    // Revisit [cebro] Localize message
339:                    String excMsg = "Invalid parameter.";
340:                    throw new IllegalArgumentException(excMsg);
341:                }
342:
343:                myRelId = new String(theRelId);
344:                myRelTypeName = new String(theRelTypeName);
345:                myRelObjName = theRelObjName;
346:                if (theUnregMBeanList != null) {
347:                    myUnregMBeanList = (ArrayList) (((ArrayList) theUnregMBeanList)
348:                            .clone());
349:                }
350:                if (theRoleName != null) {
351:                    myRoleName = new String(theRoleName);
352:                }
353:                if (theOldRoleValue != null) {
354:                    myOldRoleValue = (ArrayList) (((ArrayList) theOldRoleValue)
355:                            .clone());
356:                }
357:                if (theNewRoleValue != null) {
358:                    myNewRoleValue = (ArrayList) (((ArrayList) theNewRoleValue)
359:                            .clone());
360:                }
361:                return;
362:            }
363:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.