Source Code Cross Referenced for WorkflowManager.java in  » Workflow-Engines » xflow1.2 » xflow » client » 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 » xflow1.2 » xflow.client 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ====================================================================
003:         *
004:         * XFLOW - Process Management System
005:         * Copyright (C) 2003 Rob Tan
006:         * All rights reserved.
007:         *
008:         * Redistribution and use in source and binary forms, with or without
009:         * modification, are permitted provided that the following conditions
010:         * are met:
011:         * 
012:         * 1. Redistributions of source code must retain the above copyright
013:         *    notice, this list of conditions, and the following disclaimer.
014:         *
015:         * 2. Redistributions in binary form must reproduce the above copyright
016:         *    notice, this list of conditions, and the disclaimer that follows 
017:         *    these conditions in the documentation and/or other materials 
018:         *    provided with the distribution.
019:         *
020:         * 3. The name "XFlow" must not be used to endorse or promote products
021:         *    derived from this software without prior written permission.  For
022:         *    written permission, please contact rcktan@yahoo.com
023:         * 
024:         * 4. Products derived from this software may not be called "XFlow", nor
025:         *    may "XFlow" appear in their name, without prior written permission
026:         *    from the XFlow Project Management (rcktan@yahoo.com)
027:         * 
028:         * In addition, we request (but do not require) that you include in the 
029:         * end-user documentation provided with the redistribution and/or in the 
030:         * software itself an acknowledgement equivalent to the following:
031:         *     "This product includes software developed by the
032:         *      XFlow Project (http://xflow.sourceforge.net/)."
033:         * Alternatively, the acknowledgment may be graphical using the logos 
034:         * available at http://xflow.sourceforge.net/
035:         *
036:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
037:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
038:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
039:         * DISCLAIMED.  IN NO EVENT SHALL THE XFLOW AUTHORS OR THE PROJECT
040:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
041:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
042:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
043:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
044:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
045:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
046:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
047:         * SUCH DAMAGE.
048:         *
049:         * ====================================================================
050:         * This software consists of voluntary contributions made by many 
051:         * individuals on behalf of the XFlow Project and was originally 
052:         * created by Rob Tan (rcktan@yahoo.com)
053:         * For more information on the XFlow Project, please see:
054:         *           <http://xflow.sourceforge.net/>.
055:         * ====================================================================
056:         */
057:        package xflow.client;
058:
059:        import java.util.*;
060:        import xflow.common.*;
061:        import xflow.protocol.*;
062:        import xflow.messaging.*;
063:        import xflow.util.*;
064:        import xflow.security.*;
065:
066:        /**
067:         *  WorkflowManager contains all workflow administrative functions.
068:         *  Clients needing to perform functions such as starting/aborting workflows,
069:         *  deploying workflows, etc should invoke methods from this class.
070:         */
071:        public class WorkflowManager {
072:
073:            public static final String XFLOW = "XFLOW";
074:            public static final String BPEL = "BPEL";
075:
076:            /**
077:             *  Deploys a workflow model from an XML document
078:             *
079:             *  @param    xml        the XML document
080:             *  @param    type       the XML document type 
081:             *                       valid type currently supported is: XFLOW. 
082:             *                       BPEL in the near future 
083:             *  @param    user       the user           
084:             *  @exception XflowException
085:             */
086:            public static void deployModel(String xml, String type, User user)
087:                    throws XflowException {
088:                DeployModelRequest req = new DeployModelRequest();
089:                req.user = user;
090:                req.xml = xml;
091:                req.type = type;
092:                DeployModelResponse resp = (DeployModelResponse) sendRequest(req);
093:            }
094:
095:            /**
096:             *  Starts a workflow. 
097:             *
098:             *  @param workflowName  the workflow name
099:             *  @param workItem      the work item
100:             *  @param user          the initiator of the workflow
101:             *  @return the workflow ID of the newly created workflow instance
102:             *  @exception XflowException
103:             */
104:            public static WorkflowId startWorkflow(String workflowName,
105:                    WorkItem workItem, User user) throws XflowException {
106:
107:                StartWorkflowRequest req = new StartWorkflowRequest();
108:                req.workflowName = workflowName;
109:                req.workItem = workItem;
110:                req.user = user;
111:
112:                StartWorkflowResponse resp = (StartWorkflowResponse) sendRequest(req);
113:                return resp.workflowId;
114:            }
115:
116:            /**
117:             *  Starts a workflow with a specified version
118:             *
119:             *  @param workflowName    the workflow name
120:             *  @param workflowVersion the workflow version
121:             *  @param workItem        the work item
122:             *  @param user            the initiator of the workflow
123:             *  @return the workflow ID of the newly created workflow instance
124:             *  @exception XflowException
125:             */
126:            public static WorkflowId startWorkflow(String workflowName,
127:                    int workflowVersion, WorkItem workItem, User user)
128:                    throws XflowException {
129:
130:                StartWorkflowRequest req = new StartWorkflowRequest();
131:                req.workflowName = workflowName;
132:                req.version = workflowVersion;
133:                req.workItem = workItem;
134:                req.user = user;
135:
136:                StartWorkflowResponse resp = (StartWorkflowResponse) sendRequest(req);
137:                return resp.workflowId;
138:            }
139:
140:            /**
141:             *  Aborts an active workflow instance
142:             *
143:             *  @param workflowId      the workflow instance ID
144:             *  @param user            the user requesting the abort
145:             *  @exception XflowException
146:             */
147:            public static void abortWorkflow(WorkflowId workflowId, User user)
148:                    throws XflowException {
149:
150:                AbortWorkflowRequest req = new AbortWorkflowRequest();
151:                req.workflowId = workflowId;
152:                req.user = user;
153:
154:                AbortWorkflowResponse resp = (AbortWorkflowResponse) sendRequest(req);
155:            }
156:
157:            /**
158:             *  Suspends an active workflow instance
159:             *
160:             *  @param workflowId      the workflow instance ID
161:             *  @param user            the user requesting the suspend
162:             *  @exception XflowException
163:             */
164:            public static void suspendWorkflow(WorkflowId workflowId, User user)
165:                    throws XflowException {
166:
167:                SuspendWorkflowRequest req = new SuspendWorkflowRequest();
168:                req.workflowId = workflowId;
169:                req.user = user;
170:
171:                SuspendWorkflowResponse resp = (SuspendWorkflowResponse) sendRequest(req);
172:            }
173:
174:            /**
175:             *  Resumes a suspended workflow instance
176:             *
177:             *  @param workflowId      the workflow instance ID
178:             *  @param user            the user requesting the resume
179:             *  @exception XflowException
180:             */
181:            public static void resumeWorkflow(WorkflowId workflowId, User user)
182:                    throws XflowException {
183:
184:                ResumeWorkflowRequest req = new ResumeWorkflowRequest();
185:                req.workflowId = workflowId;
186:                req.user = user;
187:
188:                ResumeWorkflowResponse resp = (ResumeWorkflowResponse) sendRequest(req);
189:            }
190:
191:            /**
192:             *  Gets the workflow state
193:             *
194:             *  @param workflowId      the workflow instance ID
195:             *  @param user            the user 
196:             *  @return the workflow state
197:             *  @exception XflowException
198:             */
199:            public static WorkflowState getWorkflowState(WorkflowId workflowId,
200:                    User user) throws XflowException {
201:
202:                GetWorkflowStateRequest req = new GetWorkflowStateRequest();
203:                req.workflowId = workflowId;
204:                req.user = user;
205:
206:                GetWorkflowStateResponse resp = (GetWorkflowStateResponse) sendRequest(req);
207:                return resp.workflowState;
208:            }
209:
210:            /**
211:             *  Sets a variable for a specified workflow instance
212:             *
213:             *  @param workflowId      the workflow instance ID
214:             *  @param variableName    the variable name
215:             *  @param variableValue   the variable value - must be serializable
216:             *  @param user            the user 
217:             *  @exception XflowException
218:             */
219:            public static void setVariable(WorkflowId workflowId,
220:                    String variableName, Object variableValue, User user)
221:                    throws XflowException {
222:                SetVariableRequest req = new SetVariableRequest();
223:                req.workflowId = workflowId;
224:                req.variableName = variableName;
225:                req.variableValue = variableValue;
226:                req.user = user;
227:
228:                SetVariableResponse resp = (SetVariableResponse) sendRequest(req);
229:            }
230:
231:            /**
232:             *  Gets a variable for a specified workflow instance
233:             *
234:             *  @param workflowId      the workflow instance ID
235:             *  @param variableName    the variable name
236:             *  @param user            the user 
237:             *  @return the variable value
238:             *  @exception XflowException
239:             */
240:            public static Object getVariable(WorkflowId workflowId,
241:                    String variableName, User user) throws XflowException {
242:
243:                GetVariableRequest req = new GetVariableRequest();
244:                req.workflowId = workflowId;
245:                req.variableName = variableName;
246:                req.user = user;
247:                GetVariableResponse resp = (GetVariableResponse) sendRequest(req);
248:                return resp.variableValue;
249:            }
250:
251:            /**
252:             *  Gets all active workflow instances
253:             *
254:             *  @param user            the user 
255:             *  @return the list of WorkflowState objects of currently active workflow instances
256:             *  @exception XflowException
257:             */
258:            public static Vector getActiveWorkflows(User user)
259:                    throws XflowException {
260:
261:                GetActiveWorkflowsRequest req = new GetActiveWorkflowsRequest();
262:                req.user = user;
263:                GetActiveWorkflowsResponse resp = (GetActiveWorkflowsResponse) sendRequest(req);
264:                return resp.activeWorkflows;
265:            }
266:
267:            /**
268:             *  Gets all workflow instances
269:             *
270:             *  @param user            the user 
271:             *  @return the list of WorkflowState objects of all workflow instances
272:             *  @exception XflowException
273:             */
274:            public static Vector getAllWorkflows(User user)
275:                    throws XflowException {
276:
277:                GetAllWorkflowsRequest req = new GetAllWorkflowsRequest();
278:                req.user = user;
279:                GetAllWorkflowsResponse resp = (GetAllWorkflowsResponse) sendRequest(req);
280:                return resp.workflows;
281:            }
282:
283:            /**
284:             *  Gets all workflow instances
285:             *
286:             *  @param name            the workflow model name
287:             *  @param user            the user 
288:             *  @return the list of WorkflowState objects of all workflow instances
289:             *  @exception XflowException
290:             */
291:            public static Vector getAllWorkflowsByName(String name, User user)
292:                    throws XflowException {
293:
294:                GetWorkflowsByNameRequest req = new GetWorkflowsByNameRequest();
295:                req.user = user;
296:                req.name = name;
297:                GetWorkflowsByNameResponse resp = (GetWorkflowsByNameResponse) sendRequest(req);
298:                return resp.workflows;
299:            }
300:
301:            /**
302:             *  Gets all process nodes participating in  a workflow instance
303:             *
304:             *  @param    workflowId      the workflow instance ID
305:             *  @param    user            the user 
306:             *  @return the list of Node objects
307:             *  @exception XflowException
308:             */
309:            public static Vector getProcessNodes(WorkflowId workflowId,
310:                    User user) throws XflowException {
311:                GetProcessNodesRequest req = new GetProcessNodesRequest();
312:                req.user = user;
313:                req.workflowId = workflowId;
314:                GetProcessNodesResponse resp = (GetProcessNodesResponse) sendRequest(req);
315:                return resp.nodes;
316:            }
317:
318:            /**
319:             *  Gets all process nodes participating in  a workflow instance
320:             *
321:             *  @param    workflowName     the workflow model name
322:             *  @param    workflowVersion  the workflow version (-1 means get the latest)
323:             *  @param    nodeName         the node name
324:             *  @param    user            the user 
325:             *  @return the Node object
326:             *  @exception XflowException
327:             */
328:            public static Node getNodeByName(String workflowName,
329:                    int workflowVersion, String name, User user)
330:                    throws XflowException {
331:                GetNodeByNameRequest req = new GetNodeByNameRequest();
332:                req.user = user;
333:                req.workflowName = workflowName;
334:                req.version = workflowVersion;
335:                req.nodeName = name;
336:                GetNodeByNameResponse resp = (GetNodeByNameResponse) sendRequest(req);
337:                return resp.node;
338:            }
339:
340:            /**
341:             *  Gets all deployed workflow models
342:             *
343:             *  @return the list of WorkflowModel objects
344:             *  @exception XflowException
345:             */
346:            public static Vector getWorkflowModels(User user)
347:                    throws XflowException {
348:                GetModelsRequest req = new GetModelsRequest();
349:                req.user = user;
350:                GetModelsResponse resp = (GetModelsResponse) sendRequest(req);
351:                return resp.models;
352:            }
353:
354:            private static Response sendRequest(Request req)
355:                    throws XflowException {
356:
357:                req.replyName = Util.generateUniqueStringId();
358:                try {
359:                    Response resp = SynchQueueMessaging.sendRequest(req);
360:                    if (resp.responseCode != Response.SUCCESS) {
361:                        System.out.println("FAILURE response from server.");
362:                        throw new XflowException(resp.message);
363:                    }
364:                    return resp;
365:                } catch (Exception t) {
366:                    throw new XflowException(t.getMessage());
367:                }
368:            }
369:
370:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.