Source Code Cross Referenced for DefaultToolInvocationHandler.java in  » Workflow-Engines » wfmopen-2.1.1 » de » danet » an » workflow » ejbs » core » 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.core 
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: DefaultToolInvocationHandler.java,v 1.7 2007/07/08 20:35:01 mlipp Exp $
021:         *
022:         * $Log: DefaultToolInvocationHandler.java,v $
023:         * Revision 1.7  2007/07/08 20:35:01  mlipp
024:         * Even more usage of local EJB interfaces.
025:         *
026:         * Revision 1.6  2007/05/03 21:58:16  mlipp
027:         * Internal refactoring for making better use of local EJBs.
028:         *
029:         * Revision 1.5  2007/03/27 21:59:43  mlipp
030:         * Fixed lots of checkstyle warnings.
031:         *
032:         * Revision 1.4  2006/09/29 12:32:10  drmlipp
033:         * Consistently using WfMOpen as projct name now.
034:         *
035:         * Revision 1.3  2005/08/25 13:24:22  drmlipp
036:         * Synchronized with 1.3.1p6.
037:         *
038:         * Revision 1.2.2.1  2005/08/24 14:14:52  drmlipp
039:         * Started implementation of exception mapping.
040:         *
041:         * Revision 1.2  2005/01/07 14:58:59  drmlipp
042:         * Made Queuer EJB a local EJB. Not expecting significant performance
043:         * gains from this ;-), but it is somehow makes sense.
044:         *
045:         * Revision 1.1.1.1  2004/08/18 15:17:38  drmlipp
046:         * Update to 1.2
047:         *
048:         * Revision 1.4  2004/07/13 14:59:12  lipp
049:         * Added possibility to get activity's container without involving
050:         * activity in current transaction.
051:         *
052:         * Revision 1.3  2004/07/11 19:58:02  lipp
053:         * Fixed problem with getEJBObject not returning a NoSuchObjectException.
054:         *
055:         * Revision 1.2  2004/04/12 19:33:52  lipp
056:         * Clarified application invocation interface.
057:         *
058:         * Revision 1.1  2004/02/21 21:31:00  lipp
059:         * Some more refactoring to resolve cyclic dependencies.
060:         *
061:         * Revision 1.17  2004/02/20 15:57:06  lipp
062:         * Adedd repeating invocation for TransactionRolledbackLocalException.
063:         *
064:         * Revision 1.16  2003/12/08 14:08:13  lipp
065:         * Execute tool termination in own transaction.
066:         *
067:         * Revision 1.15  2003/11/18 14:32:12  lipp
068:         * Removed tool invocation optimization (may be re-introduced later).
069:         *
070:         * Revision 1.14  2003/10/25 21:00:15  lipp
071:         * Made AuditEventQueuer the general queuer.
072:         *
073:         * Revision 1.13  2003/06/27 08:51:45  lipp
074:         * Fixed copyright/license information.
075:         *
076:         * Revision 1.12  2003/05/06 13:21:30  lipp
077:         * Resolved cyclic dependency.
078:         *
079:         * Revision 1.11  2003/05/02 14:55:58  lipp
080:         * Resolved some more package dependencies.
081:         *
082:         * Revision 1.10  2003/03/31 16:50:28  huaiyang
083:         * Logging using common-logging.
084:         *
085:         * Revision 1.9  2002/12/19 21:37:42  lipp
086:         * Reorganized interfaces.
087:         *
088:         * Revision 1.8  2002/11/26 11:23:29  lipp
089:         * Modified RemoteException comment.
090:         *
091:         * Revision 1.7  2002/10/08 13:52:36  lipp
092:         * Merged branch new-state-handling.
093:         *
094:         * Revision 1.6.2.1  2002/10/08 13:04:35  lipp
095:         * Reimplementing state handling, activity start to complete cycle.
096:         *
097:         * Revision 1.6  2002/10/02 20:54:40  lipp
098:         * Event handling partially reorganized.
099:         *
100:         * Revision 1.5  2002/10/02 10:58:13  lipp
101:         * Modifications for tool invocation.
102:         *
103:         * Revision 1.4  2002/09/26 20:03:36  lipp
104:         * Reorganized tool invocation.
105:         *
106:         * Revision 1.3  2002/09/26 15:26:23  lipp
107:         * Temporarily disabled new invocation mode.
108:         *
109:         * Revision 1.2  2002/09/26 15:11:36  lipp
110:         * Extended tool invocation.
111:         *
112:         * Revision 1.1  2002/09/25 15:16:34  lipp
113:         * Reorganized tool invocation layer dependencies.
114:         *
115:         */
116:        package de.danet.an.workflow.ejbs.core;
117:
118:        import java.util.HashMap;
119:        import java.util.Map;
120:
121:        import java.rmi.RemoteException;
122:
123:        import javax.ejb.EJBException;
124:        import javax.ejb.EJBObject;
125:
126:        import de.danet.an.workflow.api.Activity;
127:        import de.danet.an.workflow.api.ActivityUniqueKey;
128:        import de.danet.an.workflow.apix.ExtActivity;
129:        import de.danet.an.workflow.domain.ToolInvocationHandler;
130:
131:        import de.danet.an.workflow.ejbs.admin.WorkflowEngineLocal;
132:        import de.danet.an.workflow.ejbs.util.ApplInvokerEJB;
133:        import de.danet.an.workflow.ejbs.util.QueuerLocal;
134:        import de.danet.an.workflow.internalapi.ExtApplication;
135:        import de.danet.an.workflow.spis.aii.ApplicationNotStoppedException;
136:
137:        /**
138:         * This class provides a JMS/EJB based invocation handler that supports
139:         * asynchronous invocation and invocation in a separate transaction.
140:         *
141:         * @author <a href="mailto:lipp@danet.de"></a>
142:         * @version $Revision: 1.7 $
143:         */
144:
145:        public class DefaultToolInvocationHandler implements 
146:                ToolInvocationHandler {
147:
148:            private static final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
149:                    .getLog(DefaultToolInvocationHandler.class);
150:
151:            private WorkflowEngineLocal engine = null;
152:            private QueuerLocal queuer = null;
153:
154:            /**
155:             * Creates an instance of
156:             * <code>DefaultToolInvocationHandler</code>.
157:             * @param theEngine the engine to be used
158:             * @param theQueuer the queuer to be used
159:             */
160:            public DefaultToolInvocationHandler(WorkflowEngineLocal theEngine,
161:                    QueuerLocal theQueuer) {
162:                engine = theEngine;
163:                queuer = theQueuer;
164:            }
165:
166:            /**
167:             * Invoke the tool.
168:             *
169:             * @param appl the application description of the tool.
170:             * @param auk the activity's unique key.
171:             * @param act the <code>WfActivity</code>.
172:             * @param params the invocation parameters.
173:             */
174:            public void invoke(ExtApplication appl, ActivityUniqueKey auk,
175:                    ExtActivity act, Map params) {
176:                if (appl.isDirectInvocable()) {
177:                    if (logger.isDebugEnabled()) {
178:                        logger.debug("Invoking " + appl + " directly");
179:                    }
180:                    try {
181:                        ApplInvokerEJB.doInvoke(engine, queuer, act, appl,
182:                                params, false);
183:                    } catch (RemoteException e) {
184:                        throw new EJBException(e);
185:                    }
186:                    return;
187:                }
188:                if (logger.isDebugEnabled()) {
189:                    logger.debug("Invoking " + appl + " using queue");
190:                }
191:                Map args = new HashMap();
192:                args.put("appl", appl);
193:                args.put("params", params);
194:                Object ah = null;
195:                try {
196:                    if (act instanceof  EJBObject) {
197:                        ah = ((ActivityProxy) ActivityProxy.wrap(act, true))
198:                                .getRefInfo();
199:                    } else if (act instanceof  ActivityProxy) {
200:                        ah = ((ActivityProxy) act).getRefInfo();
201:                    } else {
202:                        logger
203:                                .error("Object of invalid type passed as activity: "
204:                                        + act.getClass());
205:                    }
206:                } catch (RemoteException e) {
207:                    throw new EJBException(e);
208:                }
209:                args.put("activity", ah);
210:                args.put("activityUniqueKey", auk);
211:                queuer.queueToolInvocation(args);
212:            }
213:
214:            /**
215:             * Terminate the tool.
216:             *
217:             * @param appl the application description of the tool.
218:             * @param act the <code>WfActivity</code>.
219:             * @throws ApplicationNotStoppedException if termination is not possible.
220:             */
221:            public void terminate(ExtApplication appl, Activity act)
222:                    throws ApplicationNotStoppedException {
223:                while (true) {
224:                    try {
225:                        engine.doTerminateLocal(appl, act);
226:                        break;
227:                    } catch (EJBException e) {
228:                        logger.warn("Error while terminating, repeating: "
229:                                + e.getMessage());
230:                    }
231:                }
232:            }
233:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.