Source Code Cross Referenced for NotifyingEventAuditManager.java in  » Workflow-Engines » shark » org » enhydra » shark » eventaudit » 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 » Workflow Engines » shark » org.enhydra.shark.eventaudit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.enhydra.shark.eventaudit;
002:
003:        import java.util.ArrayList;
004:        import java.util.HashMap;
005:        import java.util.HashSet;
006:        import java.util.Iterator;
007:        import java.util.List;
008:        import java.util.Map;
009:        import java.util.Set;
010:        import org.enhydra.shark.api.client.wfmc.wapi.WMSessionHandle;
011:        import org.enhydra.shark.api.internal.eventaudit.AssignmentEventAuditPersistenceObject;
012:        import org.enhydra.shark.api.internal.eventaudit.CreateProcessEventAuditPersistenceObject;
013:        import org.enhydra.shark.api.internal.eventaudit.DataEventAuditPersistenceObject;
014:        import org.enhydra.shark.api.internal.eventaudit.EventAuditException;
015:        import org.enhydra.shark.api.internal.eventaudit.EventAuditManagerInterface;
016:        import org.enhydra.shark.api.internal.eventaudit.EventAuditPersistenceInterface;
017:        import org.enhydra.shark.api.internal.eventaudit.StateEventAuditPersistenceObject;
018:        import org.enhydra.shark.api.internal.working.CallbackUtilities;
019:
020:        /**
021:         * TODO: document
022:         * 
023:         * @author <a href="daniel.frey@xmatrix.ch">Daniel Frey </a>
024:         * @version 0.2
025:         */
026:        public class NotifyingEventAuditManager implements 
027:                EventAuditManagerInterface {
028:            public static final EventType DATA_EVENT_TYPE = new EventType(
029:                    DataEventAuditPersistenceObject.class);
030:            public static final EventType ASSIGNMENT_EVENT_TYPE = new EventType(
031:                    AssignmentEventAuditPersistenceObject.class);
032:            public static final EventType STATE_EVENT_TYPE = new EventType(
033:                    StateEventAuditPersistenceObject.class);
034:            public static final EventType CREATION_EVENT_TYPE = new EventType(
035:                    CreateProcessEventAuditPersistenceObject.class);
036:            // private static final Logger LOGGER =
037:            // Logger.getLogger(NotifyingEventAuditManager.class);
038:            // private static final boolean DEBUG = LOGGER.isDebugEnabled();
039:            private static final Map listeners = new HashMap();
040:            private static CallbackUtilities cus;
041:            private static boolean DEBUG;
042:
043:            public void configure(CallbackUtilities _cus) throws Exception {
044:                cus = _cus;
045:                DEBUG = Boolean.valueOf(
046:                        cus.getProperty("NotifyingEventAuditManager.Debug",
047:                                "false")).booleanValue();
048:            }
049:
050:            public void persist(WMSessionHandle shandle,
051:                    AssignmentEventAuditPersistenceObject aea)
052:                    throws EventAuditException {
053:                fire(aea, ASSIGNMENT_EVENT_TYPE);
054:            }
055:
056:            public void persist(WMSessionHandle shandle,
057:                    DataEventAuditPersistenceObject dea)
058:                    throws EventAuditException {
059:                fire(dea, DATA_EVENT_TYPE);
060:            }
061:
062:            public void persist(WMSessionHandle shandle,
063:                    StateEventAuditPersistenceObject sea)
064:                    throws EventAuditException {
065:                fire(sea, STATE_EVENT_TYPE);
066:            }
067:
068:            public void persist(WMSessionHandle shandle,
069:                    CreateProcessEventAuditPersistenceObject cpea)
070:                    throws EventAuditException {
071:                fire(cpea, CREATION_EVENT_TYPE);
072:            }
073:
074:            public boolean restore(WMSessionHandle shandle,
075:                    AssignmentEventAuditPersistenceObject aea)
076:                    throws EventAuditException {
077:                fire(aea, ASSIGNMENT_EVENT_TYPE);
078:                return false;
079:            }
080:
081:            public boolean restore(WMSessionHandle shandle,
082:                    DataEventAuditPersistenceObject dea)
083:                    throws EventAuditException {
084:                fire(dea, DATA_EVENT_TYPE);
085:                return false;
086:            }
087:
088:            public boolean restore(WMSessionHandle shandle,
089:                    StateEventAuditPersistenceObject sea)
090:                    throws EventAuditException {
091:                fire(sea, STATE_EVENT_TYPE);
092:                return false;
093:            }
094:
095:            public boolean restore(WMSessionHandle shandle,
096:                    CreateProcessEventAuditPersistenceObject cpea)
097:                    throws EventAuditException {
098:                fire(cpea, CREATION_EVENT_TYPE);
099:                return false;
100:            }
101:
102:            public List restoreProcessHistory(WMSessionHandle shandle,
103:                    String procId) throws EventAuditException {
104:                return new ArrayList();
105:            }
106:
107:            public List restoreActivityHistory(WMSessionHandle shandle,
108:                    String procId, String actId) throws EventAuditException {
109:                return new ArrayList();
110:            }
111:
112:            public void delete(WMSessionHandle shandle,
113:                    AssignmentEventAuditPersistenceObject aea)
114:                    throws EventAuditException {
115:                fire(aea, ASSIGNMENT_EVENT_TYPE);
116:            }
117:
118:            public void delete(WMSessionHandle shandle,
119:                    DataEventAuditPersistenceObject dea)
120:                    throws EventAuditException {
121:                fire(dea, DATA_EVENT_TYPE);
122:            }
123:
124:            public void delete(WMSessionHandle shandle,
125:                    StateEventAuditPersistenceObject sea)
126:                    throws EventAuditException {
127:                fire(sea, STATE_EVENT_TYPE);
128:            }
129:
130:            public void delete(WMSessionHandle shandle,
131:                    CreateProcessEventAuditPersistenceObject cpea)
132:                    throws EventAuditException {
133:                fire(cpea, CREATION_EVENT_TYPE);
134:            }
135:
136:            private static void fire(EventAuditPersistenceInterface persister,
137:                    EventType type) {
138:                synchronized (listeners) {
139:                    if (DEBUG) {
140:                        cus
141:                                .debug(
142:                                        null,
143:                                        "firing event for "
144:                                                + (type == null ? "all types "
145:                                                        : "type \"" + type
146:                                                                + "\"")
147:                                                + (persister.getActivityId() == null ? ""
148:                                                        : ", activity \""
149:                                                                + persister
150:                                                                        .getActivityId()
151:                                                                + "\"")
152:                                                + (persister.getProcessId() == null ? ""
153:                                                        : ", instance \""
154:                                                                + persister
155:                                                                        .getProcessId()
156:                                                                + "\"")
157:                                                + (persister
158:                                                        .getProcessDefinitionId() == null ? ""
159:                                                        : ", process \""
160:                                                                + persister
161:                                                                        .getProcessDefinitionId()
162:                                                                + "\"")
163:                                                + (persister.getPackageId() == null ? ""
164:                                                        : ", package \""
165:                                                                + persister
166:                                                                        .getPackageId()
167:                                                                + "\""));
168:                    }
169:                    final Set listenerset = new HashSet();
170:                    listenerset.addAll(collectListeners((Map) listeners
171:                            .get(null), persister));
172:                    listenerset.addAll(collectListeners((Map) listeners
173:                            .get(type), persister));
174:                    listenerset.remove(null);
175:                    for (final Iterator iterator = listenerset.iterator(); iterator
176:                            .hasNext();) {
177:                        final EventAuditListener listener = (EventAuditListener) iterator
178:                                .next();
179:                        final EventAuditEvent event = new EventAuditEvent(
180:                                NotifyingEventAuditManager.class);
181:                        event.setPersister(persister);
182:                        listener.eventAuditChanged(event);
183:                    }
184:                }
185:            }
186:
187:            private static Set collectListeners(final Map allTypes,
188:                    EventAuditPersistenceInterface persister) {
189:                List list;
190:                final Set listenerset = new HashSet();
191:                if (allTypes != null) {
192:                    list = (List) allTypes.get(null);
193:                    if (list != null) {
194:                        listenerset.addAll(list);
195:                    }
196:                    list = (List) allTypes.get(persister.getPackageId());
197:                    if (list != null) {
198:                        listenerset.addAll(list);
199:                    }
200:                    list = (List) allTypes.get(persister.getActivityId());
201:                    if (list != null) {
202:                        listenerset.addAll(list);
203:                    }
204:                    list = (List) allTypes.get(persister.getProcessId());
205:                    if (list != null) {
206:                        listenerset.addAll(list);
207:                    }
208:                    list = (List) allTypes.get(persister
209:                            .getProcessDefinitionId());
210:                    if (list != null) {
211:                        listenerset.addAll(list);
212:                    }
213:                }
214:                return listenerset;
215:            }
216:
217:            public static void addEventAuditListener(
218:                    final EventAuditListener listener) {
219:                addEventAuditListener(listener, null);
220:            }
221:
222:            public static void addEventAuditListener(
223:                    final EventAuditListener listener, final EventType type) {
224:                addEventAuditListener(listener, type, null);
225:            }
226:
227:            public static void addEventAuditListener(
228:                    final EventAuditListener listener, final EventType type,
229:                    final String id) {
230:                Map hash = (Map) listeners.get(type);
231:                if (hash == null) {
232:                    hash = new HashMap();
233:                    listeners.put(type, hash);
234:                }
235:                List list = (List) hash.get(id);
236:                if (list == null) {
237:                    list = new ArrayList();
238:                    hash.put(id, list);
239:                }
240:                list.add(listener);
241:            }
242:
243:            public static void removeEventAuditListener(
244:                    final EventAuditListener listener) {
245:                removeEventAuditListener(listener, null, null);
246:            }
247:
248:            public static void removeEventAuditListener(
249:                    final EventAuditListener listener, final EventType type) {
250:                removeEventAuditListener(listener, type, null);
251:            }
252:
253:            public static void removeEventAuditListener(
254:                    final EventAuditListener listener, final EventType type,
255:                    final String id) {
256:                final Map hash = (Map) listeners.get(type);
257:                if (hash == null) {
258:                    return;
259:                }
260:                final List list = (List) hash.get(id);
261:                if (list == null) {
262:                    return;
263:                }
264:                list.remove(listener);
265:            }
266:
267:            private static class EventType {
268:                private String name;
269:
270:                private EventType(Class type) {
271:                    final String full = type.getName();
272:                    name = full.substring(full.lastIndexOf('.') + 1);
273:                }
274:
275:                public String toString() {
276:                    return name;
277:                }
278:            }
279:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.