Source Code Cross Referenced for PropertyEventDispatcher.java in  » Net » openfire » org » jivesoftware » util » 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 » Net » openfire » org.jivesoftware.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $RCSfile$
003:         * $Revision: 8589 $
004:         * $Date: 2007-06-21 13:08:03 -0700 (Thu, 21 Jun 2007) $
005:         *
006:         * Copyright (C) 2004-2005 Jive Software. All rights reserved.
007:         *
008:         * This software is published under the terms of the GNU Public License (GPL),
009:         * a copy of which is included in this distribution.
010:         */package org.jivesoftware.util;
011:
012:        import java.util.Map;
013:        import java.util.Set;
014:        import java.util.concurrent.CopyOnWriteArraySet;
015:
016:        /**
017:         * Dispatches property events. Each event has a {@link EventType type}
018:         * and optional parameters, as follows:<p>
019:         *
020:         * <table border="1">
021:         * <tr><th>Event Type</th><th>Extra Params</th></tr>
022:         * <tr><td>{@link EventType#property_set property_set}</td><td>A param named <tt>value</tt> that
023:         *      has the value of the property set.</td></tr>
024:         * <tr><td>{@link EventType#property_deleted property_deleted}</td><td><i>None</i></td></tr>
025:         * <tr><td>{@link EventType#xml_property_set xml_property_set}</td><td>A param named <tt>value</tt> that
026:         *      has the value of the property set.</td></tr>
027:         * <tr><td>{@link EventType#xml_property_deleted xml_property_deleted}</td><td><i>None</i></td></tr>
028:         * </table>
029:         *
030:         * @author Matt Tucker
031:         */
032:        public class PropertyEventDispatcher {
033:
034:            private static Set<PropertyEventListener> listeners = new CopyOnWriteArraySet<PropertyEventListener>();
035:
036:            private PropertyEventDispatcher() {
037:                // Not instantiable.
038:            }
039:
040:            /**
041:             * Registers a listener to receive events.
042:             *
043:             * @param listener the listener.
044:             */
045:            public static void addListener(PropertyEventListener listener) {
046:                if (listener == null) {
047:                    throw new NullPointerException();
048:                }
049:                listeners.add(listener);
050:            }
051:
052:            /**
053:             * Unregisters a listener to receive events.
054:             *
055:             * @param listener the listener.
056:             */
057:            public static void removeListener(PropertyEventListener listener) {
058:                listeners.remove(listener);
059:            }
060:
061:            /**
062:             * Dispatches an event to all listeners.
063:             *
064:             * @param property the property.
065:             * @param eventType the event type.
066:             * @param params event parameters.
067:             */
068:            public static void dispatchEvent(String property,
069:                    EventType eventType, Map<String, Object> params) {
070:                for (PropertyEventListener listener : listeners) {
071:                    try {
072:                        switch (eventType) {
073:                        case property_set: {
074:                            listener.propertySet(property, params);
075:                            break;
076:                        }
077:                        case property_deleted: {
078:                            listener.propertyDeleted(property, params);
079:                            break;
080:                        }
081:                        case xml_property_set: {
082:                            listener.xmlPropertySet(property, params);
083:                            break;
084:                        }
085:                        case xml_property_deleted: {
086:                            listener.xmlPropertyDeleted(property, params);
087:                            break;
088:                        }
089:                        default:
090:                            break;
091:                        }
092:                    } catch (Exception e) {
093:                        Log.error(e);
094:                    }
095:                }
096:            }
097:
098:            /**
099:             * Represents valid event types.
100:             */
101:            public enum EventType {
102:
103:                /**
104:                 * A property was set.
105:                 */
106:                property_set,
107:
108:                /**
109:                 * A property was deleted.
110:                 */
111:                property_deleted,
112:
113:                /**
114:                 * An XML property was set.
115:                 */
116:                xml_property_set,
117:
118:                /**
119:                 * An XML property was deleted.
120:                 */
121:                xml_property_deleted;
122:            }
123:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.