Source Code Cross Referenced for SmartWfExecutionObject.java in  » Workflow-Engines » wfmopen-2.1.1 » process » 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 » wfmopen 2.1.1 » process 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package process;
002:
003:        import java.rmi.RemoteException;
004:
005:        import javax.naming.TimeLimitExceededException;
006:
007:        import de.danet.an.workflow.omgcore.AlreadySuspendedException;
008:        import de.danet.an.workflow.omgcore.CannotResumeException;
009:        import de.danet.an.workflow.omgcore.CannotStopException;
010:        import de.danet.an.workflow.omgcore.CannotSuspendException;
011:        import de.danet.an.workflow.omgcore.InvalidStateException;
012:        import de.danet.an.workflow.omgcore.NotRunningException;
013:        import de.danet.an.workflow.omgcore.NotSuspendedException;
014:        import de.danet.an.workflow.omgcore.TransitionNotAllowedException;
015:        import de.danet.an.workflow.omgcore.WfExecutionObject;
016:
017:        /**
018:         * Describe class <code>SmartWfExecutionObject</code> here.
019:         *
020:         * @author <a href="mailto:weidauer@danet.de">Christian Weidauer</a>
021:         * @version 1.0
022:         */
023:        public class SmartWfExecutionObject {
024:
025:            /**
026:             * Describe variable <code>wfeo</code> here.
027:             *
028:             */
029:            protected WfExecutionObject wfeo = null;
030:            /**
031:             * Describe variable <code>setStateDirectly</code> here.
032:             *
033:             */
034:            protected boolean setStateDirectly = false;
035:
036:            private EventWatch eventWatch;
037:
038:            private String awaitingState;
039:
040:            /**
041:             * Creates a new <code>SmartWfExecutionObject</code> instance.
042:             *
043:             * @param wfeo a <code>WfExecutionObject</code> value
044:             * @param setStateDirectly a <code>boolean</code> value
045:             */
046:            public SmartWfExecutionObject(WfExecutionObject wfeo,
047:                    boolean setStateDirectly) throws Exception {
048:                this .wfeo = wfeo;
049:                this .setStateDirectly = setStateDirectly;
050:                eventWatch = new EventWatch(wfeo.key());
051:            }
052:
053:            /**
054:             * Creates a new <code>SmartWfExecutionObject</code> instance.
055:             *
056:             * @param wfeo a <code>WfExecutionObject</code> value
057:             */
058:            public SmartWfExecutionObject(WfExecutionObject wfeo)
059:                    throws Exception {
060:                this (wfeo, false);
061:            }
062:
063:            /**
064:             * Return the key.
065:             * @return the key.
066:             */
067:            public String key() {
068:                boolean remoteExceptionCaught = false;
069:                do {
070:                    remoteExceptionCaught = false;
071:                    try {
072:                        return wfeo.key();
073:                    } catch (RemoteException re) {
074:                        remoteExceptionCaught = true;
075:                    }
076:                } while (remoteExceptionCaught);
077:                return null; // notreached
078:            }
079:
080:            /**
081:             * Describe <code>waitForState</code> method here.
082:             *
083:             * @param stateToCheck a <code>String</code> value
084:             * @exception Exception if an error occurs
085:             */
086:            public void setupWaitForState(String stateToCheck) throws Exception {
087:                setupWaitForState(stateToCheck, false);
088:            }
089:
090:            /**
091:             * Describe <code>waitForState</code> method here.
092:             *
093:             * @param stateToCheck a <code>String</code> value
094:             * @exception Exception if an error occurs
095:             */
096:            public void setupWaitForState(String stateToCheck, boolean log)
097:                    throws Exception {
098:                awaitingState = stateToCheck;
099:                if (this  instanceof  SmartWfProcess) {
100:                    eventWatch.setup(key(), null, null, stateToCheck, log);
101:                } else {
102:                    eventWatch.setup(null, key(), null, stateToCheck, log);
103:                }
104:            }
105:
106:            public void waitForState() throws Exception {
107:                try {
108:                    eventWatch.waitForEvent();
109:                } catch (TimeLimitExceededException e) {
110:                    throw new StateNotReachedException(this , awaitingState, e
111:                            .getMessage());
112:                }
113:            }
114:
115:            /**
116:             * Describe <code>state</code> method here.
117:             *
118:             * @return a <code>String</code> value
119:             */
120:            public String state() {
121:                boolean remoteExceptionCaught = false;
122:                String state = "";
123:                do {
124:                    remoteExceptionCaught = false;
125:                    try {
126:                        state = wfeo.state();
127:                    } catch (RemoteException re) {
128:                        remoteExceptionCaught = true;
129:                    }
130:                } while (remoteExceptionCaught);
131:                return state;
132:            }
133:
134:            /**
135:             * Describe <code>hasState</code> method here.
136:             *
137:             * @param stateToCheck a <code>String</code> value
138:             * @return a <code>boolean</code> value
139:             */
140:            public boolean hasState(String stateToCheck) {
141:                return state().startsWith(stateToCheck);
142:            }
143:
144:            /**
145:             * Describe <code>name</code> method here.
146:             *
147:             * @return a <code>String</code> value
148:             */
149:            public String name() {
150:                boolean remoteExceptionCaught = false;
151:                String name = "";
152:                do {
153:                    remoteExceptionCaught = false;
154:                    try {
155:                        name = wfeo.name();
156:                    } catch (RemoteException re) {
157:                        remoteExceptionCaught = true;
158:                    }
159:                } while (remoteExceptionCaught);
160:                return name;
161:            }
162:
163:            /**
164:             * Sets the state of a WfExecutionObject by calling  
165:             * suspend() (setStateDirectly == false) or by calling  
166:             * setState() (setStateDirectly == true)
167:             * The intended transition is from open.running to 
168:             * open.not_running.suspended.
169:             * @exception RemoteException if an error occurs
170:             * @exception CannotSuspendException if an error occurs
171:             * @exception NotRunningException if an error occurs
172:             * @exception AlreadySuspendedException if an error occurs
173:             * @exception InvalidStateException if an error occurs
174:             * @exception TransitionNotAllowedException if an error occurs
175:             */
176:            public void suspend() throws RemoteException,
177:                    CannotSuspendException, NotRunningException,
178:                    AlreadySuspendedException, InvalidStateException,
179:                    TransitionNotAllowedException {
180:                boolean remoteExceptionCaught = false;
181:                do {
182:                    remoteExceptionCaught = false;
183:                    try {
184:                        if (setStateDirectly) {
185:                            wfeo.changeState("open.not_running.suspended");
186:                        } else {
187:                            wfeo.suspend();
188:                        }
189:                    } catch (RemoteException re) {
190:                        remoteExceptionCaught = true;
191:                    }
192:                } while (remoteExceptionCaught);
193:            }
194:
195:            /**
196:             * Sets the state of a WfExecutionObject by calling  
197:             * resume() (setStateDirectly == false) or by calling  
198:             * setState() (setStateDirectly == true). 
199:             * The intended transition is from open.not_running.suspended to 
200:             * open.running.
201:             * @exception RemoteException if an error occurs
202:             * @exception CannotResumeException if an error occurs
203:             * @exception NotRunningException if an error occurs
204:             * @exception NotSuspendedException if an error occurs
205:             * @exception InvalidStateException if an error occurs
206:             * @exception TransitionNotAllowedException if an error occurs
207:             */
208:            public void resume() throws RemoteException, CannotResumeException,
209:                    NotRunningException, NotSuspendedException,
210:                    InvalidStateException, TransitionNotAllowedException {
211:                boolean remoteExceptionCaught = false;
212:                do {
213:                    remoteExceptionCaught = false;
214:                    try {
215:                        if (setStateDirectly) {
216:                            wfeo.changeState("open.running");
217:                        } else {
218:                            wfeo.resume();
219:                        }
220:                    } catch (RemoteException re) {
221:                        remoteExceptionCaught = true;
222:                    }
223:                } while (remoteExceptionCaught);
224:            }
225:
226:            /**
227:             * Sets the state of a WfExecutionObject by calling  
228:             * abort() (setStateDirectly == false) or by calling  
229:             * setState() (setStateDirectly == true). 
230:             * The intended transition is from open.not_running.suspended to 
231:             * closed.aborted.
232:             * @exception RemoteException if an error occurs
233:             * @exception NotRunningException if an error occurs
234:             * @exception NotSuspendedException if an error occurs
235:             * @exception InvalidStateException if an error occurs
236:             * @exception TransitionNotAllowedException if an error occurs
237:             * @exception CannotStopException if an error occurs
238:             */
239:            public void abort() throws RemoteException, NotRunningException,
240:                    NotSuspendedException, InvalidStateException,
241:                    TransitionNotAllowedException, CannotStopException {
242:                boolean remoteExceptionCaught = false;
243:                do {
244:                    remoteExceptionCaught = false;
245:                    try {
246:                        if (setStateDirectly) {
247:                            wfeo.changeState("closed.aborted");
248:                        } else {
249:                            wfeo.abort();
250:                        }
251:                    } catch (RemoteException re) {
252:                        remoteExceptionCaught = true;
253:                    }
254:                } while (remoteExceptionCaught);
255:            }
256:
257:            /**
258:             * Sets the state of a WfExecutionObject by calling  
259:             * terminate() (setStateDirectly == false) or by calling  
260:             * setState() (setStateDirectly == true). 
261:             * The intended transition is to 
262:             * closed.terminate.
263:             * @exception RemoteException if an error occurs
264:             * @exception CannotStopException if an error occurs
265:             * @exception InvalidStateException if an error occurs
266:             * @exception NotRunningException if an error occurs
267:             * @exception TransitionNotAllowedException if an error occurs
268:             */
269:            public void terminate() throws RemoteException,
270:                    CannotStopException, InvalidStateException,
271:                    NotRunningException, TransitionNotAllowedException {
272:                boolean remoteExceptionCaught = false;
273:                do {
274:                    remoteExceptionCaught = false;
275:                    try {
276:                        if (setStateDirectly) {
277:                            wfeo.changeState("closed.terminated");
278:                        } else {
279:                            wfeo.terminate();
280:                        }
281:                    } catch (RemoteException re) {
282:                        remoteExceptionCaught = true;
283:                    }
284:                } while (remoteExceptionCaught);
285:            }
286:
287:            /**
288:             * Describe <code>changeState</code> method here.
289:             *
290:             * @param state a <code>String</code> value
291:             * @exception RemoteException if an error occurs
292:             * @exception TransitionNotAllowedException if an error occurs
293:             * @exception InvalidStateException if an error occurs
294:             */
295:            public void changeState(String state) throws RemoteException,
296:                    TransitionNotAllowedException, InvalidStateException {
297:                boolean remoteExceptionCaught = false;
298:                do {
299:                    remoteExceptionCaught = false;
300:                    try {
301:                        wfeo.changeState(state);
302:                    } catch (RemoteException re) {
303:                        remoteExceptionCaught = true;
304:                    }
305:                } while (remoteExceptionCaught);
306:            }
307:
308:            public String toString() {
309:                return name() + "[key=" + key() + "]";
310:            }
311:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.