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


001:        /**
002:         * $RCSfile$
003:         * $Revision: 1705 $
004:         * $Date: 2005-07-26 14:10:33 -0300 (Tue, 26 Jul 2005) $
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.openfire.event;
011:
012:        import org.jivesoftware.util.Log;
013:        import org.jivesoftware.openfire.group.Group;
014:
015:        import java.util.List;
016:        import java.util.Map;
017:        import java.util.concurrent.CopyOnWriteArrayList;
018:
019:        /**
020:         * Dispatches group events. Each event has a {@link EventType type}
021:         * and optional parameters, as follows:<p>
022:         *
023:         * <table border="1">
024:         * <tr><th>Event Type</th><th>Extra Params</th></tr>
025:         * <tr><td>{@link EventType#group_created group_created}</td><td><i>None</i></td></tr>
026:         * <tr><td>{@link EventType#group_deleting group_deleting}</td><td><i>None</i></td></tr>
027:         * <tr><td>{@link EventType#member_added member_added}</td><td>A param named <tt>member</tt> with a String username as a
028:         *      payload</td></tr>
029:         * <tr><td>{@link EventType#member_removed member_removed}</td><td>A param named <tt>member</tt> with a String username as a
030:         *      payload</td></tr>
031:         * <tr><td>{@link EventType#admin_added admin_added}</td><td>A param named <tt>admin</tt> with a String username
032:         *      as a payload</td></tr>
033:         * <tr><td>{@link EventType#admin_removed admin_removed}</td><td>A param named <tt>admin</tt> with a String username
034:         *      as a payload</td></tr>
035:         * <tr valign="top"><td>{@link EventType#group_modified group_modified}</td><td>
036:         * <table><tr><td><b>Reason</b></td><td><b>Key</b></td><td><b>Value</b></td></tr>
037:         *      <tr><td colspan="3">Name modified</td></tr>
038:         *      <tr><td>&nbsp;</td><td>type</td><td>nameModified</td></tr>
039:         *      <tr><td>&nbsp;</td><td>originalValue</td><td><i>(Name before it was modified)</i>
040:         * </td></tr>
041:         *      <tr><td colspan="3"><hr></td></tr>
042:         *      <tr><td colspan="3">Description modified</td></tr>
043:         *      <tr><td>&nbsp;</td><td>type</td><td>descriptionModified</td></tr>
044:         *      <tr><td>&nbsp;</td><td>originalValue</td><td><i>(Description before it was
045:         * modified)</i></td></tr>
046:         *      <tr><td colspan="3"><hr></td></tr>
047:         *      <tr><td colspan="3">Property modified</td></tr>
048:         *      <tr><td>&nbsp;</td><td>type</td><td>propertyModified</td></tr>
049:         *      <tr><td>&nbsp;</td><td>propertyKey</td><td><i>(Name of the property)</i></td>
050:         * </tr>
051:         *      <tr><td>&nbsp;</td><td>originalValue</td><td><i>(Property value before it was
052:         * modified)</i></td></tr>
053:         *      <tr><td colspan="3"><hr></td></tr>
054:         *      <tr><td colspan="3">Property added</td></tr>
055:         *      <tr><td>&nbsp;</td><td>type</td><td>propertyAdded</td></tr>
056:         *      <tr><td>&nbsp;</td><td>propertyKey</td><td><i>(Name of the new property)</i></td>
057:         * </tr>
058:         *      <tr><td colspan="3"><hr></td></tr>
059:         *      <tr><td colspan="3">Property deleted</td></tr>
060:         *      <tr><td>&nbsp;</td><td>type</td><td>propertyDeleted</td></tr>
061:         *      <tr><td>&nbsp;</td><td>propertyKey</td><td><i>(Name of the property deleted)</i></td></tr></table></td></tr>
062:         * </table>
063:         *
064:         * @author Matt Tucker
065:         */
066:        public class GroupEventDispatcher {
067:
068:            private static List<GroupEventListener> listeners = new CopyOnWriteArrayList<GroupEventListener>();
069:
070:            private GroupEventDispatcher() {
071:                // Not instantiable.
072:            }
073:
074:            /**
075:             * Registers a listener to receive events.
076:             *
077:             * @param listener the listener.
078:             */
079:            public static void addListener(GroupEventListener listener) {
080:                if (listener == null) {
081:                    throw new NullPointerException();
082:                }
083:                listeners.add(listener);
084:            }
085:
086:            /**
087:             * Unregisters a listener to receive events.
088:             *
089:             * @param listener the listener.
090:             */
091:            public static void removeListener(GroupEventListener listener) {
092:                listeners.remove(listener);
093:            }
094:
095:            /**
096:             * Dispatches an event to all listeners.
097:             *
098:             * @param group the group.
099:             * @param eventType the event type.
100:             * @param params event parameters.
101:             */
102:            public static void dispatchEvent(Group group, EventType eventType,
103:                    Map params) {
104:                for (GroupEventListener listener : listeners) {
105:                    try {
106:                        switch (eventType) {
107:                        case group_created: {
108:                            listener.groupCreated(group, params);
109:                            break;
110:                        }
111:                        case group_deleting: {
112:                            listener.groupDeleting(group, params);
113:                            break;
114:                        }
115:                        case member_added: {
116:                            listener.memberAdded(group, params);
117:                            break;
118:                        }
119:                        case member_removed: {
120:                            listener.memberRemoved(group, params);
121:                            break;
122:                        }
123:                        case admin_added: {
124:                            listener.adminAdded(group, params);
125:                            break;
126:                        }
127:                        case admin_removed: {
128:                            listener.adminRemoved(group, params);
129:                            break;
130:                        }
131:                        case group_modified: {
132:                            listener.groupModified(group, params);
133:                            break;
134:                        }
135:                        default:
136:                            break;
137:                        }
138:                    } catch (Exception e) {
139:                        Log.error(e);
140:                    }
141:                }
142:            }
143:
144:            /**
145:             * Represents valid event types.
146:             */
147:            public enum EventType {
148:
149:                /**
150:                 * A new group was created.
151:                 */
152:                group_created,
153:
154:                /**
155:                 * A group is about to be deleted. Note that this event is fired before
156:                 * a group is actually deleted. This allows for referential cleanup
157:                 * before the group is gone.
158:                 */
159:                group_deleting,
160:
161:                /**
162:                 * The name, description, or extended property of a group was changed.
163:                 */
164:                group_modified,
165:
166:                /**
167:                 * A member was added to a group.
168:                 */
169:                member_added,
170:
171:                /**
172:                 * A member was removed from a group.
173:                 */
174:                member_removed,
175:
176:                /**
177:                 * An administrator was added to a group.
178:                 */
179:                admin_added,
180:
181:                /**
182:                 * An administrator was removed from a group.
183:                 */
184:                admin_removed;
185:            }
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.