Source Code Cross Referenced for RuntimeApplicationToolAgent.java in  » Workflow-Engines » shark » org » enhydra » shark » toolagent » 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 » shark » org.enhydra.shark.toolagent 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.enhydra.shark.toolagent;
002:
003:        import java.io.IOException;
004:
005:        import org.enhydra.shark.api.client.wfmc.wapi.WMSessionHandle;
006:        import org.enhydra.shark.api.client.wfservice.WMEntity;
007:        import org.enhydra.shark.api.internal.toolagent.AppParameter;
008:        import org.enhydra.shark.api.internal.toolagent.ApplicationBusy;
009:        import org.enhydra.shark.api.internal.toolagent.ApplicationNotDefined;
010:        import org.enhydra.shark.api.internal.toolagent.ApplicationNotStarted;
011:        import org.enhydra.shark.api.internal.toolagent.ToolAgentGeneralException;
012:        import org.enhydra.shark.xpdl.XPDLConstants;
013:
014:        /**
015:         * Tool agent that can execute some system application.
016:         * @author Sasa Bojanic
017:         * @version 1.0
018:         */
019:        public class RuntimeApplicationToolAgent extends AbstractToolAgent {
020:
021:            public static final long APP_MODE_SYNCHRONOUS = 0;
022:            public static final long APP_MODE_ASYNCHRONOUS = 1;
023:
024:            private Process p;
025:
026:            public void invokeApplication(WMSessionHandle shandle, long handle,
027:                    WMEntity appInfo, WMEntity toolInfo,
028:                    String applicationName, String procInstId, String assId,
029:                    AppParameter[] parameters, Integer appMode)
030:                    throws ApplicationNotStarted, ApplicationNotDefined,
031:                    ApplicationBusy, ToolAgentGeneralException {
032:
033:                super 
034:                        .invokeApplication(shandle, handle, appInfo, toolInfo,
035:                                applicationName, procInstId, assId, parameters,
036:                                appMode);
037:
038:                try {
039:                    status = APP_STATUS_RUNNING;
040:
041:                    StringBuffer buffer = new StringBuffer();
042:
043:                    if (appName == null || appName.trim().length() == 0) {
044:                        readParamsFromExtAttributes((String) parameters[0].the_value);
045:                    }
046:
047:                    buffer.append(appName);
048:
049:                    // ignore 1. param, this is ext. attribs.
050:                    buffer.append(" ");
051:                    if (parameters != null) {
052:                        for (int i = 1; i < parameters.length; i++) {
053:                            if (parameters[i].the_mode
054:                                    .equals(XPDLConstants.FORMAL_PARAMETER_MODE_IN)
055:                                    || parameters[i].the_mode
056:                                            .equals(XPDLConstants.FORMAL_PARAMETER_MODE_INOUT)) {
057:                                try {
058:                                    buffer
059:                                            .append((String) parameters[i].the_value);
060:                                    buffer.append(" ");
061:                                } catch (Throwable ex) {
062:                                }
063:                            }
064:                        }
065:                    }
066:
067:                    Runtime rt = Runtime.getRuntime();
068:                    p = rt.exec(buffer.toString().substring(0,
069:                            buffer.length() - 1));
070:                    if (appMode != null
071:                            && appMode.intValue() == APP_MODE_SYNCHRONOUS) {
072:                        p.waitFor();
073:                    }
074:
075:                    status = APP_STATUS_FINISHED;
076:
077:                } catch (IOException ioe) {
078:                    cus
079:                            .error(
080:                                    shandle,
081:                                    "RuntimeApplicationToolAgent - application "
082:                                            + appName
083:                                            + " terminated incorrectly, can't find executable: "
084:                                            + ioe);
085:                    throw new ApplicationNotDefined("Can't find executable "
086:                            + appName, ioe);
087:                } catch (Throwable ex) {
088:                    cus
089:                            .error(shandle,
090:                                    "RuntimeApplicationToolAgent - application "
091:                                            + appName
092:                                            + " terminated incorrectly " + ex);
093:                    status = APP_STATUS_INVALID;
094:                    throw new ToolAgentGeneralException(ex);
095:                }
096:
097:            }
098:
099:            /*public void terminate () {
100:             try {
101:             p.destroy();
102:             if (appMode.equals(APP_MODE_SYNCHRONOUS)) {
103:             status=APP_STATUS_TERMINATED;
104:             }
105:             } catch (Throwable ex) {}
106:             }*/
107:
108:            public String getInfo(WMSessionHandle shandle)
109:                    throws ToolAgentGeneralException {
110:                String i = "Executes some system applications like notepad or any other executable application."
111:                        + "\nIt is important that this application should be in the system path of machine where shark is running."
112:                        + "\nf you use application mode 0 (zero), the tool agent will wait until the executable application "
113:                        + "\nis completed, and if you choose application status other then 0 the tool agent will finish its work as "
114:                        + "\nsoon as the executable application is started (this usually happens immediately), and shark "
115:                        + "\nwill proceed to the next activity, even if the executable application is still running "
116:                        + "\n(this is asynchronous starting of some external applications)"
117:                        + "\nThis tool agent accepts parameters (AppParameter class instances), but does not modify any."
118:                        + "\nThe parameters sent to this tool agents, for which the corresponding application definition "
119:                        + "\nformal parameters are of \"IN\" type, and whose data type is string, are added as suffixes to "
120:                        + "\nthe application name, and resulting application that is started could be something like "
121:                        + "\n             \"notepad c:\\Shark\\readme\""
122:                        + "\n"
123:                        + "\nThis tool agent is able to understand the extended attributes with the following names:"
124:                        + "\n     * AppName - value of this attribute should represent the executable application name to "
125:                        + "\n                 be executed by tool agent (must be in a system path)"
126:                        + "\n     * AppMode - value of this attribute should represent the mode of execution, if set to "
127:                        + "\n                 0 (zero), tool agent will wait until the executable application is finished."
128:                        + "\n"
129:                        + "\n NOTE: Tool agent will read extended attributes only if they are called through"
130:                        + "\n       Default tool agent (not by shark directly) and this is the case when information "
131:                        + "\n       on which tool agent to start for XPDL application definition is not contained in mappings";
132:                return i;
133:            }
134:
135:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.