Source Code Cross Referenced for ProcessMgrStub.java in  » Workflow-Engines » wfmopen-2.1.1 » de » danet » an » workflow » ejbs » admin » 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.ejbs.admin 
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: ProcessMgrStub.java,v 1.3 2007/05/03 21:58:25 mlipp Exp $
021:         *
022:         * $Log: ProcessMgrStub.java,v $
023:         * Revision 1.3  2007/05/03 21:58:25  mlipp
024:         * Internal refactoring for making better use of local EJBs.
025:         *
026:         * Revision 1.2  2006/09/29 12:32:10  drmlipp
027:         * Consistently using WfMOpen as projct name now.
028:         *
029:         * Revision 1.1.1.2  2004/08/18 15:17:38  drmlipp
030:         * Update to 1.2
031:         *
032:         * Revision 1.23  2004/02/21 21:52:11  lipp
033:         * Moved ActivityFinder and ProcessMgrStub back to admin package.
034:         *
035:         * Revision 1.1  2004/02/21 21:31:00  lipp
036:         * Some more refactoring to resolve cyclic dependencies.
037:         *
038:         * Revision 1.21  2004/02/12 16:13:53  lipp
039:         * Renamed method for finding processes by data item value.
040:         *
041:         * Revision 1.20  2004/02/09 15:15:29  lipp
042:         * Support for looking up processes by the value of a data item.
043:         *
044:         * Revision 1.19  2003/06/27 08:51:45  lipp
045:         * Fixed copyright/license information.
046:         *
047:         * Revision 1.18  2003/04/26 16:11:14  lipp
048:         * Moved some classes to reduce package dependencies.
049:         *
050:         * Revision 1.17  2003/04/23 14:27:35  lipp
051:         * Improved modelling of header data.
052:         *
053:         * Revision 1.16  2003/04/19 18:33:29  lipp
054:         * Improved handling of info.
055:         *
056:         * Revision 1.15  2003/04/08 12:30:24  lipp
057:         * Implemented veriosn and category.
058:         *
059:         * Revision 1.14  2003/04/08 11:53:17  lipp
060:         * ResultSignature implemented.
061:         *
062:         * Revision 1.13  2003/04/08 11:49:05  lipp
063:         * ResultSignature implemented.
064:         *
065:         * Revision 1.12  2003/03/31 16:50:28  huaiyang
066:         * Logging using common-logging.
067:         *
068:         * Revision 1.11  2003/03/04 13:46:09  lipp
069:         * Renamed processCOntext to contextSignature for ProcessDefinition.
070:         *
071:         * Revision 1.10  2002/11/26 11:23:30  lipp
072:         * Modified RemoteException comment.
073:         *
074:         * Revision 1.9  2002/11/06 13:30:36  huaiyang
075:         * constructor of processMgrStub changed, modified the contextSignature.
076:         *
077:         * Revision 1.8  2002/11/04 14:35:47  huaiyang
078:         * Implements the method of contextSignature.
079:         *
080:         * Revision 1.7  2002/09/30 14:27:03  lipp
081:         * Fixed problem with unsupported version().
082:         *
083:         * Revision 1.6  2002/09/08 19:19:18  lipp
084:         * Replaced process type with process manager.
085:         *
086:         * Revision 1.5  2002/09/08 18:49:18  lipp
087:         * Proper use of packageId and processId.
088:         *
089:         * Revision 1.4  2002/08/30 13:37:05  lipp
090:         * Using Workflow engine facade now.
091:         *
092:         * Revision 1.3  2002/08/26 14:17:07  lipp
093:         * JavaDoc fixes.
094:         *
095:         * Revision 1.2  2002/08/22 08:47:29  lipp
096:         * Some minor optimizations.
097:         *
098:         * Revision 1.1  2002/08/21 22:06:47  lipp
099:         * Finished transition to ProcessMgrStub.
100:         *
101:         */
102:        package de.danet.an.workflow.ejbs.admin;
103:
104:        import java.io.IOException;
105:        import java.io.Serializable;
106:
107:        import java.util.Collection;
108:
109:        import java.rmi.RemoteException;
110:
111:        import javax.ejb.CreateException;
112:        import javax.ejb.FinderException;
113:        import javax.ejb.ObjectNotFoundException;
114:
115:        import de.danet.an.util.EJBUtil;
116:
117:        import de.danet.an.workflow.omgcore.InvalidRequesterException;
118:        import de.danet.an.workflow.omgcore.NotEnabledException;
119:        import de.danet.an.workflow.omgcore.ProcessDataInfo;
120:        import de.danet.an.workflow.omgcore.RequesterRequiredException;
121:        import de.danet.an.workflow.omgcore.TransitionNotAllowedException;
122:        import de.danet.an.workflow.omgcore.WfProcess;
123:        import de.danet.an.workflow.omgcore.WfProcessMgr;
124:        import de.danet.an.workflow.omgcore.WfRequester;
125:
126:        import de.danet.an.workflow.api.InvalidKeyException;
127:        import de.danet.an.workflow.api.Process;
128:        import de.danet.an.workflow.api.ProcessDefinition;
129:        import de.danet.an.workflow.api.ProcessMgr;
130:
131:        import de.danet.an.workflow.ejbs.admin.ProcessDefinitionDirectory;
132:        import de.danet.an.workflow.ejbs.admin.ProcessDefinitionDirectoryHome;
133:        import de.danet.an.workflow.ejbs.core.WfProcessHome;
134:
135:        /**
136:         * This class provides a client side representation of a 
137:         * <code>WfProcessMgr</code>. It acts as a mixture of intelligent proxy
138:         * and stub. As stub, however, it has no directly corresponding server.
139:         * It uses methods provided by other remote objects (notably
140:         * <code>ProcessDirectory</code> and <code>ProcessDefinitionDirectory</code>
141:         * to fulfill its tasks.
142:         *
143:         * @author <a href="mailto:lipp@danet.de"></a>
144:         * @version $Revision: 1.3 $
145:         */
146:
147:        public class ProcessMgrStub implements  ProcessMgr, Serializable {
148:
149:            private static final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
150:                    .getLog(ProcessMgrStub.class);
151:
152:            /** The package id of the process the mgr represents. */
153:            private String packageId = null;
154:
155:            /** The process id of the process the mgr represents. */
156:            private String processId = null;
157:
158:            /** The process type the mgr represents. */
159:            private String mgrName = null;
160:
161:            /** The process key of the process the mgr represents. */
162:            private String processKey = null;
163:
164:            // The home interface of the process definition directory
165:            private ProcessDefinitionDirectoryHome pddHome = null;
166:
167:            // The home interface of the process EJB
168:            private WfProcessHome processHome = null;
169:
170:            /**
171:             * Creates an instance of <code>ProcessMgrStub</code>
172:             * for the given process type.
173:             *
174:             * @param pkgId Id attribute of the process package.
175:             * @param prcId Id attribute of the process.
176:             * @param mgr the name of the process manager.
177:             * @param prcKey the key of the given process. It can be null.
178:             * @param pdh the process definition directory home interface.
179:             * @param ph the process home interface.
180:             */
181:            public ProcessMgrStub(String pkgId, String prcId, String mgr,
182:                    String prcKey, ProcessDefinitionDirectoryHome pdh,
183:                    WfProcessHome ph) {
184:                packageId = pkgId;
185:                processId = prcId;
186:                mgrName = mgr;
187:                processKey = prcKey;
188:                pddHome = pdh;
189:                processHome = ph;
190:            }
191:
192:            /**
193:             * This method delivers the type(name) of the process.
194:             * @return the name
195:             * @throws RemoteException if a system-level error occurs.
196:             */
197:            public String name() throws RemoteException {
198:                return mgrName;
199:            }
200:
201:            private ProcessDefinition procDef() throws RemoteException {
202:                ProcessDefinitionDirectory pdd = null;
203:                try {
204:                    if (processKey == null) {
205:                        pdd = pddHome.create();
206:                        return pdd
207:                                .lookupProcessDefinition(packageId, processId);
208:                    } else {
209:                        Process proc = processHome.findByProcessKey(processKey);
210:                        return proc.processDefinition();
211:                    }
212:                } catch (InvalidKeyException ivke) {
213:                    throw new IllegalStateException("Key " + packageId + "/"
214:                            + processId + " is invalid: " + ivke.getMessage());
215:                } catch (FinderException fe) {
216:                    throw new RemoteException(fe.getMessage());
217:                } catch (CreateException ce) {
218:                    logger.error(ce.getMessage(), ce);
219:                    throw new RemoteException(ce.getMessage());
220:                } finally {
221:                    EJBUtil.removeSession(pdd);
222:                }
223:            }
224:
225:            /**
226:             * Returns a category. The category is the package name from the
227:             * XPDL description.
228:             * @return the category
229:             * @throws RemoteException if a system-level error occurs.
230:             */
231:            public String category() throws RemoteException {
232:                return procDef().packageName();
233:            }
234:
235:            /**
236:             * Returns the creation date of the process from the XPDL description.
237:             * @return the creation date.
238:             * @throws RemoteException if a system-level error occurs.
239:             */
240:            public String version() throws RemoteException {
241:                return procDef().version();
242:            }
243:
244:            /**
245:             * Returns a collection with WfProcess objects from this process manager.
246:             * @return a Collection object with remote interface of WfProcess.
247:             * @throws RemoteException if a system-level error occurs.
248:             */
249:            public Collection processes() throws RemoteException {
250:                Collection processes = null;
251:                try {
252:                    processes = processHome.findByProcessMgrName(name());
253:                } catch (FinderException fe) {
254:                    logger.error(fe.getMessage(), fe);
255:                    throw new RemoteException(fe.getMessage());
256:                }
257:                return processes;
258:            }
259:
260:            /**
261:             * Returns the state of the <code>WfProcessMgr</code>.
262:             * @return ENABLED if creation of workflow processes is enabled,
263:             * otherwise DISABLED.
264:             * @throws RemoteException if a system-level error occurs.
265:             */
266:            public int processMgrState() throws RemoteException {
267:                ProcessDefinitionDirectory pdd = null;
268:                try {
269:                    pdd = pddHome.create();
270:                    if (pdd.isEnabled(packageId, processId)) {
271:                        return WfProcessMgr.ENABLED;
272:                    } else {
273:                        return WfProcessMgr.DISABLED;
274:                    }
275:                } catch (InvalidKeyException ivke) {
276:                    return WfProcessMgr.DISABLED;
277:                } catch (CreateException ce) {
278:                    logger.error(ce.getMessage(), ce);
279:                    throw new RemoteException(ce.getMessage());
280:                } finally {
281:                    EJBUtil.removeSession(pdd);
282:                }
283:            }
284:
285:            /**
286:             * Set the new state of this process manager.
287:             * @param newState the new state.
288:             * @throws TransitionNotAllowedException if the transition is not allowed
289:             * @throws RemoteException if a system-level error occurs.
290:             */
291:            public void setProcessMgrState(int newState)
292:                    throws RemoteException, TransitionNotAllowedException {
293:                ProcessDefinitionDirectory pdd = null;
294:                try {
295:                    pdd = pddHome.create();
296:                    pdd.setEnabled(packageId, processId,
297:                            newState == WfProcessMgr.ENABLED);
298:                } catch (InvalidKeyException ivke) {
299:                    throw new TransitionNotAllowedException(ivke.getMessage());
300:                } catch (CreateException ce) {
301:                    logger.error(ce.getMessage(), ce);
302:                    throw new RemoteException(ce.getMessage());
303:                } finally {
304:                    EJBUtil.removeSession(pdd);
305:                }
306:            }
307:
308:            /**
309:             * Unsupported method in this iteration of WfMOpen.
310:             * @return the description
311:             * @throws RemoteException if a system-level error occurs.
312:             */
313:            public String description() throws RemoteException {
314:                return procDef().processHeader().description();
315:            }
316:
317:            /**
318:             * Return the context signature of the process. If this process key is 
319:             * given, then find out its process definition through process; otherwise, 
320:             * through process definition directory.
321:             * @return a ProcessDataInfo object
322:             * @throws RemoteException if a system-level error occurs.
323:             */
324:            public ProcessDataInfo contextSignature() throws RemoteException {
325:                return procDef().contextSignature();
326:            }
327:
328:            /**
329:             * Unsupported method in this iteration of WfMOpen.
330:             * @return a ProcessDataInfo object
331:             * @throws RemoteException if a system-level error occurs.
332:             */
333:            public ProcessDataInfo resultSignature() throws RemoteException {
334:                return procDef().resultSignature();
335:            }
336:
337:            /**
338:             * Create a new process.
339:             * Accept any requester object with is not <code>null</code>.
340:             * @param requester WfRequester
341:             * @throws NotEnabledException if create of 
342:             * {@link de.danet.an.workflow.omgcore.WfProcess <code>WfProcess</code>} 
343:             * using a {@link de.danet.an.workflow.omgcore.WfProcessMgr <code>
344:             * WfProcessMgr</code>} that is disabled.
345:             * @throws InvalidRequesterException if requester is not validate. 
346:             * @throws RequesterRequiredException if requester is <code>null</code>
347:             * @throws RemoteException if a system-level error occurs.
348:             * @return a WfProcess object
349:             */
350:            public WfProcess createProcess(WfRequester requester)
351:                    throws RemoteException, NotEnabledException,
352:                    InvalidRequesterException, RequesterRequiredException {
353:                ProcessDefinitionDirectory pdd = null;
354:                try {
355:                    pdd = pddHome.create();
356:                    return pdd.createProcess(packageId, processId, requester);
357:                } catch (InvalidKeyException ce) {
358:                    throw new NotEnabledException(ce.getMessage());
359:                } catch (CreateException ce) {
360:                    logger.error(ce.getMessage(), ce);
361:                    throw new RemoteException(ce.getMessage());
362:                } finally {
363:                    EJBUtil.removeSession(pdd);
364:                }
365:            }
366:
367:            /**
368:             * Returns the {@link Process <code>Process</code>} with the given key.
369:             * @param key the 
370:             * {@link de.danet.an.workflow.omgcore.WfProcess#key key} of the process.
371:             * @return the process associated with the key.
372:             * @throws InvalidKeyException if no process with the given key
373:             * exists.
374:             * @throws RemoteException if a system-level error occurs.
375:             */
376:            public Process processByKey(String key) throws InvalidKeyException,
377:                    RemoteException {
378:                try {
379:                    return (Process) processHome.findByProcessKey(key);
380:                } catch (ObjectNotFoundException onfx) {
381:                    throw new InvalidKeyException("Key " + key
382:                            + " is invalid: " + onfx.getMessage());
383:                } catch (FinderException fex) {
384:                    logger.error(fex.getMessage(), fex);
385:                    throw new RemoteException(fex.getMessage());
386:                }
387:            }
388:
389:            /**
390:             * Returns all {@link Process <code>Process</code>}es that have a
391:             * given value in a particular process data item. Note that this
392:             * method may only be used for data items of type string.
393:             *
394:             * @param itemName the name of the process data item
395:             * @param itemValue the value of the process data item
396:             * @return the collection of processes
397:             * @throws RemoteException if a system-level error occurs
398:             */
399:            public Collection findByDataItem(String itemName, String itemValue)
400:                    throws RemoteException {
401:                try {
402:                    return processHome.findByProcessTypeAndDataItem(mgrName,
403:                            itemName, itemValue);
404:                } catch (FinderException fex) {
405:                    logger.error(fex.getMessage(), fex);
406:                    throw new RemoteException(fex.getMessage());
407:                }
408:
409:            }
410:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.