Source Code Cross Referenced for WfExecutionObject.java in  » Workflow-Engines » wfmopen-2.1.1 » de » danet » an » workflow » omgcore » 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 » de.danet.an.workflow.omgcore 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file is part of the WfMOpen project.
003:         * Copyright (C) 2001-2003 Danet GmbH (www.danet.de), GS-AN.
004:         * All rights reserved.
005:         *
006:         * This program is free software; you can redistribute it and/or modify
007:         * it under the terms of the GNU General Public License as published by
008:         * the Free Software Foundation; either version 2 of the License, or
009:         * (at your option) any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         * 
020:         * $Id: WfExecutionObject.java,v 1.6 2006/10/01 09:42:30 mlipp Exp $
021:         *
022:         * $Log: WfExecutionObject.java,v $
023:         * Revision 1.6  2006/10/01 09:42:30  mlipp
024:         * Removed Umlaut.
025:         *
026:         * Revision 1.5  2006/09/29 12:32:09  drmlipp
027:         * Consistently using WfMOpen as projct name now.
028:         *
029:         * Revision 1.4  2005/04/22 15:11:05  drmlipp
030:         * Merged changes from 1.3 branch up to 1.3p15.
031:         *
032:         * Revision 1.3.2.1  2005/04/19 13:53:44  drmlipp
033:         * Optimzed State.toString (used rather often).
034:         *
035:         * Revision 1.3  2005/01/13 12:40:40  drmlipp
036:         * Made serializable as implemented by an EJB.
037:         *
038:         * Revision 1.2  2005/01/02 20:49:13  mlipp
039:         * First version of debug mode.
040:         *
041:         * Revision 1.1.1.1  2003/06/30 20:05:16  drmlipp
042:         * Initial import
043:         *
044:         * Revision 1.40  2003/06/27 08:51:45  lipp
045:         * Fixed copyright/license information.
046:         *
047:         * Revision 1.39  2003/06/05 18:23:48  lipp
048:         * Optimzed method.
049:         *
050:         * Revision 1.38  2003/04/26 16:11:14  lipp
051:         * Moved some classes to reduce package dependencies.
052:         *
053:         * Revision 1.37  2003/04/25 14:50:58  lipp
054:         * Fixed javadoc errors and warnings.
055:         *
056:         * Revision 1.36  2002/11/26 11:23:29  lipp
057:         * Modified RemoteException comment.
058:         *
059:         * Revision 1.35  2002/11/19 15:14:53  lipp
060:         * New transition manager.
061:         *
062:         * Revision 1.34  2002/11/11 12:20:03  lipp
063:         * Fixed state compatibility checks.
064:         *
065:         * Revision 1.33  2002/10/21 11:54:23  lipp
066:         * Better suspend state handling.
067:         *
068:         * Revision 1.32  2002/10/18 11:16:18  lipp
069:         * Added setName.
070:         *
071:         * Revision 1.31  2002/10/09 11:17:42  lipp
072:         * Fixes to readResolve.
073:         *
074:         * Revision 1.30  2002/10/08 13:52:36  lipp
075:         * Merged branch new-state-handling.
076:         *
077:         * Revision 1.29.2.1  2002/10/07 15:04:53  lipp
078:         * Reimplementing state handling, process start to activity start.
079:         *
080:         * Revision 1.29  2002/09/27 11:31:32  huaiyang
081:         * In the readresolve method use fromString.
082:         *
083:         * Revision 1.28  2002/09/26 09:53:00  huaiyang
084:         * In readresolve method use text representation to compare.
085:         *
086:         * Revision 1.27  2002/09/25 10:48:13  lipp
087:         * Improved State implementation.
088:         *
089:         * Revision 1.26  2002/09/18 09:47:01  huaiyang
090:         * Use readResolve method to make enumerations typesafe.
091:         *
092:         * Revision 1.25  2002/07/24 08:04:42  huaiyang
093:         * doccheck.
094:         *
095:         * Revision 1.24  2002/07/23 11:53:42  huaiyang
096:         * Add javadocs.
097:         *
098:         * Revision 1.23  2002/04/03 12:53:05  lipp
099:         * JavaDoc fixes.
100:         *
101:         * Revision 1.22  2002/01/10 15:36:53  lipp
102:         * Cleaned up definition of Priority.
103:         *
104:         * Revision 1.21  2001/12/20 22:22:50  lipp
105:         * Resource release implemented.
106:         *
107:         * Revision 1.20  2001/10/09 15:13:55  lipp
108:         * Inner classes made static.
109:         *
110:         * Revision 1.19  2001/10/09 14:01:23  lipp
111:         * Minor javadoc errors fixed.
112:         *
113:         * Revision 1.18  2001/10/06 11:40:29  lipp
114:         * Some javadoc fixes.
115:         *
116:         * Revision 1.17  2001/09/07 14:43:23  lipp
117:         * whyNotRunning refined.
118:         *
119:         * Revision 1.16  2001/09/07 14:14:22  lipp
120:         * Substate not_runnable corrected (reparented).
121:         *
122:         * Revision 1.15  2001/09/07 13:43:12  lipp
123:         * New Substate not_runnable.
124:         *
125:         * Revision 1.14  2001/09/07 11:47:49  montag
126:         * new substates for open.not_running.suspended
127:         *
128:         * Revision 1.13  2001/08/24 14:00:12  lipp
129:         * Redundante Fuehrung der Detail-Status entfernt und über Methoden der
130:         * State-Klassen implementiert.
131:         *
132:         * Revision 1.12  2001/08/23 14:13:16  lipp
133:         * Status handling now conformant to "Workflow Management Application
134:         * Programming Interface (Interface 2&3)", Appendix G.
135:         *
136:         * Revision 1.11  2001/08/22 11:05:41  lipp
137:         * Minor fixes of return types of state querying functions patch.
138:         *
139:         * Revision 1.10  2001/08/21 15:48:05  lipp
140:         * Return types of state querying functions converted to
141:         * String as required by OMG (some minor bugs still left)
142:         *
143:         * Revision 1.9  2001/08/14 15:30:50  montag
144:         * get state
145:         *
146:         * Revision 1.8  2001/08/14 06:46:07  montag
147:         * set and get internalState of ExecutionObject
148:         *
149:         * Revision 1.7  2001/08/11 13:16:30  montag
150:         * State and Priority now inner classes of interface WfExecutionObject
151:         *
152:         * Revision 1.6  2001/08/01 18:25:20  montag
153:         * Priority and State
154:         *
155:         * Revision 1.5  2001/07/31 09:57:43  montag
156:         * *** empty log message ***
157:         *
158:         * Revision 1.4  2001/07/30 08:15:30  montag
159:         * Enums added.
160:         *
161:         * Revision 1.3  2001/07/26 21:00:08  lipp
162:         * Added Exceptions
163:         *
164:         * Revision 1.2  2001/07/26 15:57:40  lipp
165:         * Methods returning Collections renamed.
166:         *
167:         * Revision 1.1  2001/07/06 08:51:48  lipp
168:         * Moved from domain to omgcore
169:         *
170:         * Revision 1.3  2001/07/05 14:15:09  lipp
171:         * Rather complete version.
172:         *
173:         * Revision 1.2  2001/07/04 09:51:02  lipp
174:         * Fixed Copyright notice
175:         *
176:         */
177:        package de.danet.an.workflow.omgcore;
178:
179:        import java.io.Serializable;
180:
181:        import java.util.ArrayList;
182:        import java.util.Collection;
183:        import java.util.Date;
184:        import java.util.HashMap;
185:        import java.util.Iterator;
186:        import java.util.Map;
187:
188:        import java.rmi.RemoteException;
189:
190:        /**
191:         * <code>WfExecutionObject</code> is an abstract base interface that defines
192:         * common attributes, states, and operations for 
193:         * {@link de.danet.an.workflow.omgcore.WfProcess <code>WfProcess</code>}
194:         * and 
195:         * {@link de.danet.an.workflow.omgcore.WfActivity <code>WfActivity</code>}.
196:         **/
197:        public interface WfExecutionObject extends WfObject, Serializable {
198:
199:            /**
200:             * This class defines the top-hierachy possible states of a {@link
201:             * WfExecutionObject <code>WfExecutionObject</code>} as returned
202:             * by {@link #workflowState <code>workflowState()</code>}.
203:             */
204:            public static class State implements  Serializable {
205:                /**
206:                 * To reflect that the object is active and not finished.
207:                 */
208:                public static final State OPEN = new State("open");
209:                /**
210:                 * Reflects that the object is finished and inactive.
211:                 */
212:                public static final State CLOSED = new State("closed");
213:                static {
214:                    registerState(OPEN);
215:                    registerState(CLOSED);
216:                }
217:
218:                /** Textual representation of the state.*/
219:                private String textRepresentation = null;
220:
221:                /**
222:                 * Default constructor.
223:                 * @param text Textual representation of the state
224:                 */
225:                protected State(String text) {
226:                    textRepresentation = text;
227:                }
228:
229:                /** 
230:                 * Return the textual representation of the state. 
231:                 * @return the textual representation
232:                 */
233:                protected final String textRepresentation() {
234:                    return textRepresentation;
235:                }
236:
237:                /**
238:                 * Returns the parent in the state hierachy if all states 
239:                 * defined in this class or <code>null</code>, if this states
240:                 * are at the top level of the hierachy.
241:                 * @return parent in the state hierachy
242:                 */
243:                public State getParent() {
244:                    // State has no parents
245:                    return null;
246:                }
247:
248:                /**
249:                 * Returns the workflow state, i.e. this object.
250:                 * @return the state as <code>State</code> object.
251:                 */
252:                public State workflowState() {
253:                    return this ;
254:                }
255:
256:                /**
257:                 * Returns the workflow substate for open execution objects.
258:                 * @return the state as <code>State</code> object.
259:                 */
260:                public State whileOpenState() {
261:                    throw new IllegalStateException();
262:                }
263:
264:                /**
265:                 * Returns the workflow substate for open, not running
266:                 * execution objects.
267:                 * @return the state as <code>State</code> object.
268:                 */
269:                public State whyNotRunningState() {
270:                    throw new IllegalStateException();
271:                }
272:
273:                /**
274:                 * Returns the workflow substate for closed
275:                 * execution objects.
276:                 * @return the state as <code>State</code> object.
277:                 */
278:                public State howClosedState() {
279:                    throw new IllegalStateException();
280:                }
281:
282:                /** Cache for toString optimization. */
283:                private static Map toStringCache = new HashMap();
284:
285:                /**
286:                 * Returns the string representation of the state.
287:                 * @return string representation of the state.
288:                 */
289:                public String toString() {
290:                    String res = (String) toStringCache.get(this );
291:                    if (res != null) {
292:                        return res;
293:                    }
294:                    if (getParent() == null) {
295:                        res = textRepresentation;
296:                    } else {
297:                        res = getParent().toString() + "." + textRepresentation;
298:                    }
299:                    synchronized (toStringCache) {
300:                        toStringCache.put(this , res);
301:                    }
302:                    return res;
303:                }
304:
305:                /**
306:                 * List of registered states for the execution object.
307:                 */
308:                private static Collection knownStates; // DO NOT INITIALZE WITH null!!!
309:
310:                /**
311:                 * Register state for <code>fromString</code> evaluation.<P>
312:                 * Additionally introduced sub-states must call this method
313:                 * during their initialization if the textual representation
314:                 * is to be recognized in the <code>fromString</code> method.
315:                 * It is up to the implementor of a derived state to assure
316:                 * that the sub-state is initialized before the from String
317:                 * method is called.
318:                 * @param state the <code>State</code> to be registered.
319:                 */
320:                protected static void registerState(State state) {
321:                    synchronized (State.class) {
322:                        if (knownStates == null) {
323:                            knownStates = new ArrayList();
324:                        }
325:                        knownStates.add(state);
326:                        states = null;
327:                    }
328:                }
329:
330:                /**
331:                 * List of possible states for the execution object.
332:                 * Handles the mapping between the state name and the state object.
333:                 */
334:                private static Map states = null;
335:
336:                /**
337:                 * Get a state by name.
338:                 * @param text state name to search
339:                 * @return state object
340:                 * @throws InvalidStateException if <code>text</code> is not a valid
341:                 * state name.
342:                 */
343:                public static State fromString(String text)
344:                        throws InvalidStateException {
345:                    if (states == null) {
346:                        // Will all mappings be initialized? If "fromString"
347:                        // is called for a State that has never been used
348:                        // before, it is not registered. So let's simply use
349:                        // all States (classes) once now.
350:                        State s = State.OPEN;
351:                        s = OpenState.RUNNING;
352:                        s = ClosedState.TERMINATED;
353:                        s = NotRunningState.NOT_STARTED;
354:                        // Now initialize the map
355:                        Map sm = new HashMap();
356:                        for (Iterator itr = knownStates.iterator(); itr
357:                                .hasNext();) {
358:                            s = (State) itr.next();
359:                            sm.put(s.toString(), s);
360:                        }
361:                        states = sm;
362:                    }
363:                    State s = (State) states.get(text);
364:                    if (s == null) {
365:                        throw new InvalidStateException("Unknown state " + text);
366:                    }
367:                    return s;
368:                }
369:
370:                /**
371:                 * Checks if this state is the same state as the given state
372:                 * or a substate of the given state.
373:                 * @param s State to compare
374:                 * @return <code>true</code> if same or sub-state
375:                 * <code>false</code> else.
376:                 */
377:                public boolean isSameOrSubState(State s) {
378:                    State ref = this ;
379:                    while (ref != null) {
380:                        if (ref.equals(s)) {
381:                            return true;
382:                        }
383:                        ref = ref.getParent();
384:                    }
385:                    return false;
386:                }
387:
388:                /**
389:                 * Perform instance substitution during serialization.
390:                 */
391:                private Object readResolve() {
392:                    String repr = textRepresentation();
393:                    if (repr == null) {
394:                        throw new IllegalArgumentException(
395:                                "Unexpected error in serialization");
396:                    }
397:                    if (repr.equals(OPEN.textRepresentation())) {
398:                        return OPEN;
399:                    }
400:                    if (repr.equals(CLOSED.textRepresentation())) {
401:                        return CLOSED;
402:                    }
403:                    throw new IllegalArgumentException(
404:                            "Unexpected error in serialization");
405:                }
406:            }
407:
408:            /**
409:             * This class defines the sub-states of State.OPEN of a {@link
410:             * de.danet.an.workflow.omgcore.WfExecutionObject
411:             * <code>WfExecutionObject</code>} as returned by {@link
412:             * #whileOpenState <code>whileOpenState()</code>}.
413:             */
414:            public static class OpenState extends WfExecutionObject.State
415:                    implements  Serializable {
416:                /**
417:                 * The object is active and executing in the workflow.
418:                 */
419:                public static final OpenState RUNNING = new OpenState("running");
420:                /**
421:                 * Object is active and quiescent, but ready to execute.
422:                 */
423:                public static final OpenState NOT_RUNNING = new OpenState(
424:                        "not_running");
425:                static {
426:                    registerState(RUNNING);
427:                    registerState(NOT_RUNNING);
428:                }
429:
430:                /**
431:                 * Default constructor.
432:                 * @param text Textual representation of the state
433:                 */
434:                protected OpenState(String text) {
435:                    super (text);
436:                }
437:
438:                /**
439:                 * Returns the parent in the state hierachy if all states 
440:                 * defined in this class or <code>null</code>, if this states
441:                 * are at the top level of the hierachy.
442:                 * @return parent in the state hierachy
443:                 */
444:                public State getParent() {
445:                    // parent is State.OPEN
446:                    return State.OPEN;
447:                }
448:
449:                /**
450:                 * Returns the workflow state, i.e. the parent.
451:                 * @return the workflow state
452:                 */
453:                public State workflowState() {
454:                    return getParent();
455:                }
456:
457:                /**
458:                 * Returns the workflow substate for open execution objects.
459:                 * @return the sub-state of open state
460:                 */
461:                public State whileOpenState() {
462:                    return this ;
463:                }
464:
465:                /**
466:                 * Returns the workflow substate for open, not running
467:                 * execution objects.
468:                 * @return the sub-state of not-running state
469:                 */
470:                public State whyNotRunningState() {
471:                    throw new IllegalStateException();
472:                }
473:
474:                /**
475:                 * Returns the workflow substate for closed
476:                 * execution objects.
477:                 * @return the sub-state of closed state
478:                 */
479:                public State howClosedState() {
480:                    throw new IllegalStateException();
481:                }
482:
483:                /**
484:                 * Perform instance substitution during serialization.
485:                 */
486:                private Object readResolve() {
487:                    String repr = textRepresentation();
488:                    if (repr == null) {
489:                        throw new IllegalArgumentException(
490:                                "Unexpected error in serialization");
491:                    }
492:                    if (repr.equals(RUNNING.textRepresentation())) {
493:                        return RUNNING;
494:                    }
495:                    if (repr.equals(NOT_RUNNING.textRepresentation())) {
496:                        return NOT_RUNNING;
497:                    }
498:                    throw new IllegalArgumentException(
499:                            "Unexpected error in serialization");
500:                }
501:            }
502:
503:            /**
504:             * This class defines the sub-states of OpenState.NOT_RUNNING of a
505:             * {@link de.danet.an.workflow.omgcore.WfExecutionObject
506:             * <code>WfExecutionObject</code>} as returned by {@link
507:             * #whyNotRunningState <code>whyNotRunningState()</code>}.
508:             */
509:            public static class NotRunningState extends OpenState implements 
510:                    Serializable {
511:                /**
512:                 * Provides a state after creation where the object is active and 
513:                 * ready to be initialized and started.
514:                 */
515:                public static final NotRunningState NOT_STARTED = new NotRunningState(
516:                        "not_started");
517:                /**
518:                 * Provides a state to temporarily pause the execution of the object.
519:                 * When an execution object is suspended, no execution objects 
520:                 * depending on this object may be started.
521:                 */
522:                public static final NotRunningState SUSPENDED = new NotRunningState(
523:                        "suspended");
524:                static {
525:                    registerState(SUSPENDED);
526:                    registerState(NOT_STARTED);
527:                }
528:
529:                /**
530:                 * Default constructor.
531:                 * @param text Textual representation of the state
532:                 */
533:                protected NotRunningState(String text) {
534:                    super (text);
535:                }
536:
537:                /**
538:                 * Returns the parent in the state hierachy if all states 
539:                 * defined in this class or <code>null</code>, if this states
540:                 * are at the top level of the hierachy.
541:                 * @return parent in the state hierachy
542:                 */
543:                public State getParent() {
544:                    // parent is OpenState.NOT_RUNNING
545:                    return OpenState.NOT_RUNNING;
546:                }
547:
548:                /**
549:                 * Returns the workflow state, i.e. the grandparent.
550:                 * @return the workflow state
551:                 */
552:                public State workflowState() {
553:                    return getParent().getParent();
554:                }
555:
556:                /**
557:                 * Returns the workflow substate for open execution objects.
558:                 * @return the sub-state of open state
559:                 */
560:                public State whileOpenState() {
561:                    return getParent();
562:                }
563:
564:                /**
565:                 * Returns the workflow substate for open, not running
566:                 * execution objects.
567:                 * @return the sub-state of not-running state
568:                 */
569:                public State whyNotRunningState() {
570:                    return this ;
571:                }
572:
573:                /**
574:                 * Returns the workflow substate for closed
575:                 * execution objects.
576:                 * @return the sub-state of closed state
577:                 */
578:                public State howClosedState() {
579:                    throw new IllegalStateException();
580:                }
581:
582:                /**
583:                 * Perform instance substitution during serialization.
584:                 */
585:                private Object readResolve() {
586:                    String repr = textRepresentation();
587:                    if (repr == null) {
588:                        throw new IllegalArgumentException(
589:                                "Unexpected error in serialization");
590:                    }
591:                    if (repr.equals(SUSPENDED.textRepresentation())) {
592:                        return SUSPENDED;
593:                    }
594:                    if (repr.equals(NOT_STARTED.textRepresentation())) {
595:                        return NOT_STARTED;
596:                    }
597:                    throw new IllegalArgumentException(
598:                            "Unexpected error in serialization");
599:                }
600:            }
601:
602:            /**
603:             * This class defines the sub-states of State.CLOSED of a {@link
604:             * de.danet.an.workflow.omgcore.WfExecutionObject
605:             * <code>WfExecutionObject</code>} as returned by {@link
606:             * #howClosedState <code>howClosedState()</code>}.
607:             */
608:            public static class ClosedState extends State implements 
609:                    Serializable {
610:                /**
611:                 * When an execution object has finished its task in the overall 
612:                 * workflow process it enters the completed state; it is assumed that
613:                 * all execution objects associated with that execution object are
614:                 * completed when it enters this state.
615:                 */
616:                public static final ClosedState COMPLETED = new ClosedState(
617:                        "completed");
618:                /**
619:                 * Indicates that enactment of the execution object was stopped before
620:                 * normal completion. It is assumed that all execution objects 
621:                 * depending on this execution object (i.e., WfActivities contained 
622:                 * in a WfProcess or a WfProcess implementing a WfActivity) are either
623:                 * completed or are terminated when it enters this state.
624:                 */
625:                public static final ClosedState TERMINATED = new ClosedState(
626:                        "terminated");
627:                /**
628:                 * Indicates that the enactment of the execution object has been 
629:                 * aborted before normal execution. No assumptions on the state of 
630:                 * execution objects depending on this execution object are made when
631:                 * enters this state.
632:                 */
633:                public static final ClosedState ABORTED = new ClosedState(
634:                        "aborted");
635:                static {
636:                    registerState(COMPLETED);
637:                    registerState(TERMINATED);
638:                    registerState(ABORTED);
639:                }
640:
641:                /**
642:                 * Default constructor.
643:                 * @param text Textual representation of the state
644:                 */
645:                protected ClosedState(String text) {
646:                    super (text);
647:                }
648:
649:                /**
650:                 * Returns the parent in the state hierachy if all states 
651:                 * defined in this class or <code>null</code>, if this states
652:                 * are at the top level of the hierachy.
653:                 * @return parent in the state hierachy
654:                 */
655:                public State getParent() {
656:                    // parent is State.CLOSED
657:                    return State.CLOSED;
658:                }
659:
660:                /**
661:                 * Returns the workflow state, i.e. the parent.
662:                 * @return the workflow state
663:                 */
664:                public State workflowState() {
665:                    return getParent();
666:                }
667:
668:                /**
669:                 * Returns the workflow substate for open execution objects.
670:                 * @return the sub-state of open state
671:                 */
672:                public State whileOpenState() {
673:                    throw new IllegalStateException();
674:                }
675:
676:                /**
677:                 * Returns the workflow substate for open, not running
678:                 * execution objects.
679:                 * @return the sub-state of not-running state
680:                 */
681:                public State whyNotRunningState() {
682:                    throw new IllegalStateException();
683:                }
684:
685:                /**
686:                 * Returns the workflow substate for closed
687:                 * execution objects.
688:                 * @return the sub-state of closed state
689:                 */
690:                public State howClosedState() {
691:                    return this ;
692:                }
693:
694:                /**
695:                 * Perform instance substitution during serialization.
696:                 */
697:                private Object readResolve() {
698:                    String repr = textRepresentation();
699:                    if (repr == null) {
700:                        throw new IllegalArgumentException(
701:                                "Unexpected error in serialization");
702:                    }
703:                    if (repr.equals(COMPLETED.textRepresentation())) {
704:                        return COMPLETED;
705:                    }
706:                    if (repr.equals(TERMINATED.textRepresentation())) {
707:                        return TERMINATED;
708:                    }
709:                    if (repr.equals(ABORTED.textRepresentation())) {
710:                        return ABORTED;
711:                    }
712:                    throw new IllegalArgumentException(
713:                            "Unexpected error in serialization");
714:                }
715:            }
716:
717:            /**
718:             * Return the current state.
719:             *
720:             * @return the current <code>state</code>.
721:             * @throws RemoteException if a system-level error occurs.
722:             */
723:            State workflowState() throws RemoteException;
724:
725:            /**
726:             * Returns the workflow state for open execution objects.
727:             * @return the state as <code>State</code> object.
728:             * @throws RemoteException if a system-level error occurs.
729:             */
730:            State whileOpen() throws RemoteException;
731:
732:            /**
733:             * Returns the workflow state for open, not running execution objects.
734:             * @return the state as <code>State</code> object.
735:             * @throws RemoteException if a system-level error occurs.
736:             */
737:            State whyNotRunning() throws RemoteException;
738:
739:            /** 
740:             * Returns the workflow state for closed execution objects.
741:             * @return the state as <code>State</code> object.
742:             * @throws RemoteException If a communication error occurred.
743:             */
744:            State howClosed() throws RemoteException;
745:
746:            /**
747:             * Returns a list of all the valid states that can be reached from the 
748:             * current state.
749:             * @return A {@link java.util.Collection collection} of
750:             * all the valid states.
751:             * @throws RemoteException If a communication error occurred.
752:             */
753:            Collection validStates() throws RemoteException;
754:
755:            /**
756:             * Gets the current state of the object.
757:             * @return the current state.
758:             * @throws RemoteException If a communication error occurred.
759:             */
760:            String state() throws RemoteException;
761:
762:            /**
763:             * Updates the current state of the execution object. As a result
764:             * the state of execution objects associated with this execution object
765:             * might be updated, too.
766:             * @param newState State to change to.
767:             * @throws InvalidStateException If <code>newState</code> is an invalid
768:             * state for the execution object.
769:             * @throws TransitionNotAllowedException If the transition from the current
770:             * state to <code>newState</code> is not allowed.
771:             * @throws RemoteException If a communication error occurred.
772:             */
773:            void changeState(String newState) throws RemoteException,
774:                    InvalidStateException, TransitionNotAllowedException;
775:
776:            /**
777:             * Return human readable, descriptive identifier of the execution object.
778:             * @return string of the descriptive identifier.
779:             * @throws RemoteException If a communication error occurred.
780:             */
781:            String name() throws RemoteException;
782:
783:            /**
784:             * Set the name of this <code>WfExecutionObject</code>.
785:             * @param newValue the description of this <code>WfExecutionObject</code>.
786:             * @throws RemoteException If a communication error occurred.
787:             */
788:            void setName(String newValue) throws RemoteException;
789:
790:            /**
791:             * Identifier of the execution object.
792:             * @return string of the identifier.
793:             * @throws RemoteException If a communication error occurred.
794:             */
795:            String key() throws RemoteException;
796:
797:            /**
798:             * Get the description of this <code>WfExecutionObject</code>.
799:             * @return a string value of the description.
800:             * @throws RemoteException If a communication error occurred.
801:             */
802:            String description() throws RemoteException;
803:
804:            /**
805:             * Set the description of this <code>WfExecutionObject</code>.
806:             * @param newValue the description of this <code>WfExecutionObject</code>.
807:             * @throws RemoteException If a communication error occurred.
808:             */
809:            void setDescription(String newValue) throws RemoteException;
810:
811:            /**
812:             * Return the context of this <code>WfExecutionObject</code>.
813:             * @return the process relevant data that define the context of the 
814:             * execution object.
815:             * @throws RemoteException If a communication error occurred.
816:             */
817:            ProcessData processContext() throws RemoteException;
818:
819:            /**
820:             * Set the context of this <code>WfExecutionObject</code>.
821:             * @param newValue process relevant data that define the context of the 
822:             * execution object.
823:             * @throws RemoteException if a system-level error occurs.
824:             * @throws InvalidDataException when new process data does not match the 
825:             * signature of this <code>WfExecutionObject</code>.
826:             * @throws UpdateNotAllowedException raised when the implementation of the
827:             * WfM Facility or the specific workflow process does not allow an update 
828:             * of the context.
829:             */
830:            void setProcessContext(ProcessData newValue)
831:                    throws RemoteException, InvalidDataException,
832:                    UpdateNotAllowedException;
833:
834:            /**
835:             * Return the priority of this <code>WfExecutionObject</code>.
836:             * @return the value of the priority.
837:             * @throws RemoteException if a system-level error occurs.
838:             */
839:            int priority() throws RemoteException;
840:
841:            /**
842:             * Update the priority of this <code>WfExecutionObject</code>.
843:             * @param newValue new priority to set
844:             * @throws RemoteException if a system-level error occurs.
845:             * @throws InvalidPriorityException when the specified priority is out of 
846:             * range.
847:             * @throws UpdateNotAllowedException when the priority cannot be updated.
848:             */
849:            void setPriority(int newValue) throws RemoteException,
850:                    InvalidPriorityException, UpdateNotAllowedException;
851:
852:            /**
853:             * Return the time the state of the WfExecutionObject was changed.
854:             * @return value of the time.
855:             * @throws RemoteException if a system-level error occurs.
856:             */
857:            Date lastStateTime() throws RemoteException;
858:
859:            /**
860:             * Requests enactment of a suspended execution object to be resumed. The 
861:             * state is set to OpenState.Running (or a substate) from 
862:             * NotRunningState.SUSPENDED.
863:             * @throws RemoteException if a system-level error occurs.
864:             * @throws CannotResumeException when the execution object cannot be 
865:             * resumed. For example, resuming a WfActivity might not be allowed when 
866:             * the containing WfProcess is suspended.
867:             * @throws NotRunningException when the object is not running.
868:             * @throws NotSuspendedException when the object is not suspended.
869:             */
870:            void resume() throws RemoteException, CannotResumeException,
871:                    NotRunningException, NotSuspendedException;
872:
873:            /**
874:             * Requests enactment of an execution object to be suspended. The state is
875:             * set to NotRunningState.SUSPENDED (or one of its substates).
876:             * @throws RemoteException if a system-level error occurs.
877:             * @throws CannotSuspendException when the execution object cannot be
878:             * suspended. For example, an implementation of the WfM Facility might not
879:             * support suspension of a <code>WfActivity</code>.
880:             * @throws NotRunningException when the object is not running.
881:             * @throws AlreadySuspendedException when the object is already suspended.
882:             */
883:            void suspend() throws RemoteException, CannotSuspendException,
884:                    NotRunningException, AlreadySuspendedException;
885:
886:            /**
887:             * Requests enactment of an execution object to be terminated before its 
888:             * normal completion.
889:             * @throws RemoteException if a system-level error occurs.
890:             * @throws CannotStopException when the execution object cannot be aborted.
891:             * @throws NotRunningException when the object is not running.
892:             */
893:            void terminate() throws RemoteException, CannotStopException,
894:                    NotRunningException;
895:
896:            /**
897:             * Requests enactment of a suspended execution object to be aborted before
898:             * its normal completion. The state is set to ClosedState.ABORTED.
899:             * @throws RemoteException if a system-level error occurs.
900:             * @throws CannotStopException when the execution object cannot be aborted.
901:             * @throws NotRunningException when the object is not running.
902:             */
903:            void abort() throws RemoteException, CannotStopException,
904:                    NotRunningException;
905:
906:            /**
907:             * Return all <code>WfAuditEvent</code> items associated with this 
908:             * execution object.
909:             * @return the collection of all <code>WfAuditEvent</code> items.
910:             * @throws RemoteException if a system-level error occurs.
911:             * @throws HistoryNotAvailableException if any audit event item available.
912:             */
913:            Collection history() throws RemoteException,
914:                    HistoryNotAvailableException;
915:
916:            /**
917:             * @clientCardinality 1
918:             * @supplierCardinality 0..* 
919:             */
920:            /*#WfAuditEvent lnkWfAuditEvent;*/
921:
922:            /** @link dependency */
923:            /*#State lnkState;*/
924:
925:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.