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


001:        /*
002:         * This file is part of the WfMOpen project.
003:         * Copyright (C) 2001-2004 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: TimerCanceler.java,v 1.2 2006/09/29 12:32:10 drmlipp Exp $
021:         *
022:         * $Log: TimerCanceler.java,v $
023:         * Revision 1.2  2006/09/29 12:32:10  drmlipp
024:         * Consistently using WfMOpen as projct name now.
025:         *
026:         * Revision 1.1.1.1  2004/08/18 15:17:39  drmlipp
027:         * Update to 1.2
028:         *
029:         * Revision 1.8  2004/07/07 14:45:49  lipp
030:         * Added missing return statement.
031:         *
032:         * Revision 1.7  2004/04/12 19:33:52  lipp
033:         * Clarified application invocation interface.
034:         *
035:         * Revision 1.6  2004/04/01 09:32:07  lipp
036:         * Improved tool agent context implementtaion.
037:         *
038:         * Revision 1.5  2004/03/31 20:48:14  lipp
039:         * Cleaned up.
040:         *
041:         * Revision 1.4  2004/03/31 19:36:20  lipp
042:         * Completed implementation of Activity.abandon(String).
043:         *
044:         * Revision 1.3  2004/02/27 18:09:31  lipp
045:         * Removed overlooked hard-coding of result parameter.
046:         *
047:         * Revision 1.2  2004/02/24 13:51:21  lipp
048:         * Fixed typo.
049:         *
050:         * Revision 1.1  2004/02/20 18:56:35  lipp
051:         * Renamed package waittool to timing (much better ;-)).
052:         *
053:         * Revision 1.2  2004/02/20 15:58:22  lipp
054:         * Several WaitTool fixes.
055:         *
056:         * Revision 1.1  2004/02/19 17:55:55  lipp
057:         * Initial version of waittool.
058:         *
059:         */
060:        package de.danet.an.workflow.tools.timing;
061:
062:        import java.util.Map;
063:
064:        import java.rmi.RemoteException;
065:
066:        import de.danet.an.workflow.omgcore.CannotCompleteException;
067:        import de.danet.an.workflow.omgcore.CannotStopException;
068:        import de.danet.an.workflow.omgcore.InvalidDataException;
069:        import de.danet.an.workflow.omgcore.NotRunningException;
070:        import de.danet.an.workflow.omgcore.ProcessData;
071:        import de.danet.an.workflow.omgcore.WfExecutionObject.State;
072:
073:        import de.danet.an.workflow.api.Activity;
074:        import de.danet.an.workflow.api.ActivityUniqueKey;
075:        import de.danet.an.workflow.api.DefaultProcessData;
076:        import de.danet.an.workflow.api.FormalParameter;
077:        import de.danet.an.workflow.api.InvalidKeyException;
078:
079:        import de.danet.an.workflow.spis.aii.ApplicationNotStoppedException;
080:        import de.danet.an.workflow.spis.aii.CannotExecuteException;
081:        import de.danet.an.workflow.spis.aii.ResultProvider;
082:        import de.danet.an.workflow.tools.util.SimpleApplicationInfo;
083:
084:        /**
085:         * This class provides a tool agent that cancels a timer.
086:         *
087:         * @author <a href="mailto:lipp@danet.de">Michael Lipp</a>
088:         * @version $Revision: 1.2 $
089:         */
090:
091:        public class TimerCanceler extends ToolAgentBase implements 
092:                ResultProvider {
093:
094:            private static final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
095:                    .getLog(TimerCanceler.class);
096:
097:            /** The result container. */
098:            private ThreadLocal result = new ThreadLocal();
099:
100:            /**
101:             * Creates an instance of <code>TimerCanceler</code>
102:             * with all attributes initialized to default values.
103:             */
104:            public TimerCanceler() {
105:            }
106:
107:            /**
108:             * Executes the tool.
109:             *
110:             * @param activity an <code>Activity</code> value
111:             * @param fps the formal parameters
112:             * @param map a <code>Map</code> value
113:             * @exception CannotExecuteException if an error occurs
114:             * @exception RemoteException if an error occurs
115:             */
116:            public void invoke(Activity activity, FormalParameter[] fps, Map map)
117:                    throws CannotExecuteException, RemoteException {
118:                // Note that a RemoteException will lead to a rollback and an
119:                // automatic re-invocation of this method.
120:                long applId = ((Long) map.get(fps[0].id())).longValue();
121:                if (logger.isDebugEnabled()) {
122:                    logger.debug("Cancelling timer application " + applId);
123:                }
124:                SimpleApplicationInfo info = null;
125:                try {
126:                    info = applicationDirectory().instanceInfo(applId);
127:                    applicationDirectory().removeInstance(applId);
128:                } catch (InvalidKeyException e) {
129:                    logger.warn("Timer application " + applId
130:                            + " could not be "
131:                            + "canceled because is does not exist.");
132:                    return;
133:                }
134:                Object timer = ((Object[]) info.state())[0];
135:                timerHandler().removeTimer(timer);
136:                ActivityUniqueKey auk = info.activityUniqueKey();
137:                Activity act = null;
138:                try {
139:                    act = toolAgentContext().lookupActivity(auk);
140:                } catch (InvalidKeyException e) {
141:                    logger.warn(auk + " is unknown, cannot cancel wait tool.");
142:                    return;
143:                }
144:                ProcessData res = new DefaultProcessData();
145:                String resParam = (String) ((Object[]) info.state())[1];
146:                res.put(resParam, "CANCELED");
147:                try {
148:                    act.setResult(res);
149:                    act.complete();
150:                    if (logger.isDebugEnabled()) {
151:                        logger.debug("Timer application " + applId
152:                                + " canceled, " + auk + " completed");
153:                    }
154:                    return;
155:                } catch (InvalidDataException e) {
156:                    logger.error("Cannot set \"status\" out parameter of "
157:                            + "wait tool. Propably wrong declaration. " + auk
158:                            + " will be terminated.");
159:                } catch (CannotCompleteException e) {
160:                    logger.error("Cannot complete " + auk
161:                            + " (will be terminated): " + e.getMessage());
162:                }
163:                if (act.typedState().workflowState() == State.OPEN) {
164:                    try {
165:                        act.terminate();
166:                    } catch (CannotStopException e) {
167:                        logger.error("Cannot terminate " + auk + ": "
168:                                + e.getMessage());
169:                    } catch (NotRunningException e) {
170:                        logger.debug(auk
171:                                + " not running although state is open?");
172:                    }
173:                }
174:            }
175:
176:            /**
177:             * Application cannot be terminated, throws exception.
178:             *
179:             * @param activity the activity to be canceled
180:             * @throws ApplicationNotStoppedException if execution cannot be
181:             * terminated (see {@link ApplicationNotStoppedException
182:             * <code>ApplicationNotStoppedException</code>}).
183:             */
184:            public void terminate(Activity activity)
185:                    throws ApplicationNotStoppedException {
186:                throw new ApplicationNotStoppedException(
187:                        "Cannot terminate TimerCanceler");
188:            }
189:
190:            // Implementation of de.danet.an.workflow.spis.aii.ResultProvider
191:
192:            /**
193:             * Returns the result.
194:             *
195:             * @return a <code>Map</code> value
196:             */
197:            public Object result() {
198:                return null;
199:            }
200:
201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.