Source Code Cross Referenced for ProcessInstancesModelImpl.java in  » IDE-Netbeans » bpel » org » netbeans » modules » bpel » debugger » bdiclient » impl » 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 » IDE Netbeans » bpel » org.netbeans.modules.bpel.debugger.bdiclient.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the terms of the Common Development
003:         * and Distribution License (the License). You may not use this file except in
004:         * compliance with the License.
005:         * 
006:         * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007:         * or http://www.netbeans.org/cddl.txt.
008:         * 
009:         * When distributing Covered Code, include this CDDL Header Notice in each file
010:         * and include the License file at http://www.netbeans.org/cddl.txt.
011:         * If applicable, add the following below the CDDL Header, with the fields
012:         * enclosed by brackets [] replaced by your own identifying information:
013:         * "Portions Copyrighted [year] [name of copyright owner]"
014:         * 
015:         * The Original Software is NetBeans. The Initial Developer of the Original
016:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017:         * Microsystems, Inc. All Rights Reserved.
018:         */
019:
020:        package org.netbeans.modules.bpel.debugger.bdiclient.impl;
021:
022:        import java.util.ArrayList;
023:        import java.util.Arrays;
024:        import java.util.Collections;
025:        import java.util.HashMap;
026:        import java.util.LinkedHashMap;
027:        import java.util.LinkedList;
028:        import java.util.List;
029:        import java.util.Map;
030:        import java.util.Vector;
031:        import javax.xml.namespace.QName;
032:        import org.netbeans.modules.bpel.debugger.api.ProcessInstance;
033:        import org.netbeans.modules.bpel.debugger.api.ProcessInstancesModel;
034:        import org.netbeans.modules.bpel.debuggerbdi.rmi.api.BPELProcessInstanceRef;
035:        import org.netbeans.modules.bpel.debugger.BpelDebuggerImpl;
036:        import org.netbeans.modules.bpel.debugger.api.BpelProcess;
037:        import org.netbeans.modules.bpel.debuggerbdi.rmi.api.BPELProcessRef;
038:        import org.netbeans.modules.bpel.debuggerbdi.rmi.api.VirtualBPELEngine;
039:
040:        /**
041:         * Model for maintaining the list of process instances.
042:         * Supports notification of process state changes.
043:         *
044:         * @author Sun Microsystems
045:         */
046:        public class ProcessInstancesModelImpl implements  ProcessInstancesModel {
047:
048:            private final Vector<Listener> myListeners = new Vector<Listener>();
049:            private final BpelDebuggerImpl myDebugger;
050:
051:            private final Map<String, ProcessInstanceImpl> myProcessInstances = Collections
052:                    .synchronizedMap(new LinkedHashMap<String, ProcessInstanceImpl>());
053:
054:            private final Map<QName, BpelProcessImpl> myProcesses = new HashMap<QName, BpelProcessImpl>();
055:
056:            public ProcessInstancesModelImpl(final BpelDebuggerImpl debugger) {
057:
058:                myDebugger = debugger;
059:            }
060:
061:            public BpelDebuggerImpl getDebugger() {
062:                return myDebugger;
063:            }
064:
065:            public void clear() {
066:                myProcessInstances.clear();
067:                myListeners.clear();
068:            }
069:
070:            public ProcessInstanceImpl[] getProcessInstances() {
071:                return myProcessInstances.values().toArray(
072:                        new ProcessInstanceImpl[myProcessInstances.size()]);
073:            }
074:
075:            public ProcessInstanceImpl[] getProcessInstances(
076:                    final BpelProcess process) {
077:
078:                final List<ProcessInstance> filtered = new LinkedList<ProcessInstance>();
079:
080:                for (ProcessInstance instance : myProcessInstances.values()) {
081:                    if (instance.getProcess().equals(process)) {
082:                        filtered.add(instance);
083:                    }
084:                }
085:
086:                return filtered
087:                        .toArray(new ProcessInstanceImpl[filtered.size()]);
088:            }
089:
090:            public BpelProcessImpl[] getProcesses() {
091:                return myProcesses.values().toArray(
092:                        new BpelProcessImpl[myProcesses.size()]);
093:            }
094:
095:            public BpelProcessImpl getProcess(final BPELProcessRef processRef) {
096:
097:                final QName processQName = makeProcessQName(processRef.uri());
098:
099:                BpelProcessImpl process = myProcesses.get(processQName);
100:
101:                if (process == null) {
102:                    process = new BpelProcessImpl(processRef, myDebugger);
103:                    myProcesses.put(processQName, process);
104:                }
105:
106:                return process;
107:            }
108:
109:            public void addListener(final Listener listener) {
110:
111:                myListeners.add(listener);
112:            }
113:
114:            public void removeListener(final Listener listener) {
115:
116:                myListeners.remove(listener);
117:            }
118:
119:            protected void processUndeployed(final String uri) {
120:
121:                final QName processQName = makeProcessQName(uri);
122:                for (ProcessInstanceImpl processInstance : getProcessInstances()) {
123:                    if (processInstance.getProcessQName().equals(processQName)) {
124:                        processInstance.setUndeployed(true);
125:
126:                        if (processInstance.getState() == ProcessInstance.STATE_SUSPENDED) {
127:                            processInstance.resume();
128:                        }
129:
130:                        myProcessInstances.remove(processInstance.getId());
131:
132:                        fireProcessInstanceRemoved(processInstance);
133:                    }
134:                }
135:
136:                myProcesses.remove(processQName);
137:            }
138:
139:            protected BDIDebugFrame frameCreated(final String id,
140:                    final String processInstanceId, final String parentFrameId,
141:                    final String bpelFile, final String uri) {
142:
143:                ProcessInstanceImpl processInstance = myProcessInstances
144:                        .get(processInstanceId);
145:
146:                // If no instance with this id is registered -- we should register 
147:                // it (apply for the BPELProcessInstanceRef). If it's not 
148:                // available -- ignore the event altogether.
149:                if (processInstance == null) {
150:                    final VirtualBPELEngine engine = myDebugger
151:                            .getBDIDebugger().getVirtualBPELEngine();
152:
153:                    for (String procId : engine.allDeployedBPELs()) {
154:                        final BPELProcessRef processRef = engine
155:                                .getBPELProcess(procId);
156:
157:                        getProcess(processRef);
158:
159:                        final List<String> ids = Arrays.asList(processRef
160:                                .allProcessInstanceIDs());
161:
162:                        if (ids.contains(processInstanceId)) {
163:                            final BPELProcessInstanceRef instanceRef = processRef
164:                                    .getProcessInstance(processInstanceId);
165:
166:                            processInstanceStarted(instanceRef);
167:                            break;
168:                        }
169:                    }
170:
171:                    processInstance = myProcessInstances.get(processInstanceId);
172:
173:                    // If it's still null -- ignore the event
174:                    if (processInstance == null) {
175:                        return null;
176:                    }
177:                }
178:
179:                final BDIDebugFrame frame = processInstance.addFrame(id,
180:                        parentFrameId);
181:
182:                return frame;
183:            }
184:
185:            protected void processInstanceStarted(
186:                    final BPELProcessInstanceRef processInstanceRef) {
187:
188:                final ProcessInstanceImpl processInstance = new ProcessInstanceImpl(
189:                        this , processInstanceRef);
190:
191:                myProcessInstances
192:                        .put(processInstance.getId(), processInstance);
193:                processInstance.onProcessInstanceStarted();
194:
195:                fireProcessInstanceAdded(processInstance);
196:            }
197:
198:            protected void processInstanceDied(
199:                    final BPELProcessInstanceRef processInstanceRef) {
200:
201:                final String processInstanceId = processInstanceRef.globalID();
202:
203:                final ProcessInstanceImpl processInstance = myProcessInstances
204:                        .get(processInstanceId);
205:
206:                processInstance.onProcessInstanceDied();
207:            }
208:
209:            protected void processInstanceCompleted(
210:                    final ProcessInstanceImpl processInstance) {
211:
212:                myProcessInstances.remove(processInstance.getId());
213:
214:                fireProcessInstanceRemoved(processInstance);
215:            }
216:
217:            protected void processInstanceStateChanged(
218:                    final ProcessInstanceImpl processInstance,
219:                    final int oldState, final int newState) {
220:
221:                fireProcessInstanceStateChanged(processInstance, oldState,
222:                        newState);
223:            }
224:
225:            protected static QName makeProcessQName(String uri) {
226:                final int pos = uri.lastIndexOf('/');
227:
228:                return new QName(uri.substring(0, pos), uri.substring(pos + 1));
229:            }
230:
231:            // Private /////////////////////////////////////////////////////////////////
232:            private void fireProcessInstanceAdded(
233:                    final ProcessInstanceImpl processInstance) {
234:
235:                final Listener[] listeners = new Listener[myListeners.size()];
236:                myListeners.copyInto(listeners);
237:
238:                for (int i = 0; i < listeners.length; i++) {
239:                    listeners[i].processInstanceAdded(processInstance);
240:                }
241:            }
242:
243:            private void fireProcessInstanceRemoved(
244:                    final ProcessInstanceImpl processInstance) {
245:
246:                final Listener[] listeners = new Listener[myListeners.size()];
247:                myListeners.copyInto(listeners);
248:
249:                for (int i = 0; i < listeners.length; i++) {
250:                    listeners[i].processInstanceRemoved(processInstance);
251:                }
252:            }
253:
254:            private void fireProcessInstanceStateChanged(
255:                    final ProcessInstanceImpl processInstance,
256:                    final int oldState, final int newState) {
257:
258:                final Listener[] listeners = new Listener[myListeners.size()];
259:                myListeners.copyInto(listeners);
260:
261:                for (int i = 0; i < listeners.length; i++) {
262:                    listeners[i].processInstanceStateChanged(processInstance,
263:                            oldState, newState);
264:                }
265:            }
266:        }
w_w___w___._j___av___a___2__s__.___c___o_m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.