Source Code Cross Referenced for AttributeChangeNotificationFilter.java in  » JMX » XMOJO » javax » management » 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 » XMOJO » javax.management 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * The XMOJO Project 5
003:         * Copyright © 2003 XMOJO.org. All rights reserved.
004:
005:         * NO WARRANTY
006:
007:         * BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
008:         * THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
009:         * OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
010:         * PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
011:         * OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
012:         * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
013:         * TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE
014:         * LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
015:         * REPAIR OR CORRECTION.
016:
017:         * IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
018:         * ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
019:         * THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
020:         * GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
021:         * USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF
022:         * DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
023:         * PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE),
024:         * EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
025:         * SUCH DAMAGES.
026:         **/package javax.management;
027:
028:        import java.io.Serializable;
029:        import java.io.ObjectInputStream;
030:        import java.io.ObjectInputStream.GetField;
031:        import java.io.ObjectStreamField;
032:        import java.io.ObjectOutputStream;
033:        import java.io.ObjectOutputStream.PutField;
034:        import java.io.IOException;
035:        import java.util.Vector;
036:
037:        /**
038:         * This class implements of the {@link javax.management.NotificationFilter NotificationFilter}
039:         * interface for the {@link javax.management.AttributeChangeNotification attribute change notification}.
040:         * The filtering is performed on the name of the observed attribute.
041:         * <P>
042:         * It manages a list of enabled attribute names.
043:         * A method allows users to enable/disable as many attribute names as required.
044:         */
045:        public class AttributeChangeNotificationFilter implements 
046:                NotificationFilter, Serializable {
047:            /**
048:             * Vector that contains the enabled attribute names.
049:             * The default value is an empty vector.
050:             */
051:            private Vector enabledAttributes = new Vector();
052:
053:            /* Serial version UID */
054:            private static final long serialVersionUID = 0xa7e9cc49419e9f53L;
055:
056:            private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField(
057:                    "enabledAttributes", java.util.Vector.class) };
058:
059:            /**
060:             * The noArg constructor .
061:             */
062:            public AttributeChangeNotificationFilter() {
063:                //enabledAttributes = new Vector();
064:            }
065:
066:            /**
067:             * Invoked before sending the specified notification to the listener.
068:             * <BR>This filter compares the attribute name of the specified attribute
069:             * change notification with each enabled attribute name. If the attribute
070:             * name equals one of the enabled attribute names, the notification
071:             * must be sent to the listener and this method returns <CODE>true</CODE>.
072:             *
073:             * @param notification The attribute change notification to be sent.
074:             *
075:             * @return <CODE>true</CODE> if the notification has to be sent to
076:             * 				the listener, <CODE>false</CODE> otherwise.
077:             */
078:            public boolean isNotificationEnabled(Notification notification) {
079:                if (notification == null)
080:                    return false;
081:
082:                if (!(notification instanceof  AttributeChangeNotification))
083:                    return false;
084:
085:                String name = ((AttributeChangeNotification) notification)
086:                        .getAttributeName();
087:
088:                for (int i = 0; i < enabledAttributes.size(); i++) {
089:                    String str = (String) enabledAttributes.elementAt(i);
090:                    if (name.equals(str))
091:                        return true;
092:                }
093:
094:                return false;
095:            }
096:
097:            /**
098:             * Disables all the attribute names.
099:             */
100:            public void disableAllAttributes() {
101:                enabledAttributes.removeAllElements();
102:            }
103:
104:            /**
105:             * Disables all the attribute change notifications the attribute name of
106:             * which equals the specified attribute name to be sent to the listener.
107:             * <BR>If the specified name is not in the list of enabled attribute names,
108:             * this method has no effect.
109:             *
110:             * @param name The attribute name.
111:             */
112:            public void disableAttribute(java.lang.String name) {
113:                if (name == null)
114:                    return;
115:
116:                for (int i = 0; i < enabledAttributes.size(); i++) {
117:                    String str = (String) enabledAttributes.elementAt(i);
118:                    if (name.equals(str))
119:                        enabledAttributes.removeElementAt(i);
120:                }
121:            }
122:
123:            /**
124:             * Enables all the attribute change notifications the attribute name of
125:             * which equals the specified name to be sent to the listener.
126:             * <BR>If the specified name is already in the list of enabled attribute
127:             * names, this method has no effect.
128:             *
129:             * @param name The attribute name.
130:             *
131:             * @exception java.lang.IllegalArgumentException The attribute
132:             * 				name parameter is null.
133:             */
134:            public void enableAttribute(java.lang.String name)
135:                    throws java.lang.IllegalArgumentException {
136:                if (name == null)
137:                    throw new IllegalArgumentException(name);
138:
139:                boolean flag = false;
140:                for (int i = 0; i < enabledAttributes.size(); i++) {
141:                    String str = (String) enabledAttributes.elementAt(i);
142:                    if (name.equals(str))
143:                        flag = true;
144:                }
145:
146:                if (!flag)
147:                    enabledAttributes.add(name);
148:            }
149:
150:            /**
151:             * Gets all the enabled attribute names for this filter.
152:             *
153:             * @return The list containing all the enabled attribute names.
154:             */
155:            public Vector getEnabledAttributes() {
156:                return enabledAttributes;
157:            }
158:
159:            //-------------------------- Private methods ---------------------------//
160:
161:            private void readObject(ObjectInputStream objectinputstream)
162:                    throws IOException, ClassNotFoundException {
163:                ObjectInputStream.GetField getfield = objectinputstream
164:                        .readFields();
165:
166:                try {
167:                    enabledAttributes = (Vector) getfield.get(
168:                            "enabledAttributes", null);
169:                } catch (Exception exception) {
170:                }
171:            }
172:
173:            private void writeObject(ObjectOutputStream objectoutputstream)
174:                    throws IOException {
175:                ObjectOutputStream.PutField putfield = objectoutputstream
176:                        .putFields();
177:                putfield.put("enabledAttributes", enabledAttributes);
178:                objectoutputstream.writeFields();
179:            }
180:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.