Source Code Cross Referenced for DefaultToolAgent.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 org.enhydra.shark.api.RootError;
004:        import org.enhydra.shark.api.client.wfmc.wapi.WMSessionHandle;
005:        import org.enhydra.shark.api.client.wfservice.WMEntity;
006:        import org.enhydra.shark.api.internal.toolagent.AppParameter;
007:        import org.enhydra.shark.api.internal.toolagent.ApplicationBusy;
008:        import org.enhydra.shark.api.internal.toolagent.ApplicationNotDefined;
009:        import org.enhydra.shark.api.internal.toolagent.ApplicationNotStarted;
010:        import org.enhydra.shark.api.internal.toolagent.ToolAgent;
011:        import org.enhydra.shark.api.internal.toolagent.ToolAgentGeneralException;
012:        import org.enhydra.shark.xpdl.elements.ExtendedAttribute;
013:        import org.enhydra.shark.xpdl.elements.ExtendedAttributes;
014:
015:        /**
016:         * Tool agent that is called when there are no any mapped tool agents. It reads the ext.
017:         * attributes to find the tool agent to call. When it calls another tool agent, it just
018:         * passes it parameters and ...
019:         * 
020:         * @author Sasa Bojanic
021:         * @version 1.0
022:         */
023:        public class DefaultToolAgent extends AbstractToolAgent {
024:
025:            private final static String TOOL_AGENT_CLASS_EXT_ATTR_NAME = "ToolAgentClass";
026:
027:            private String taClass;
028:
029:            private String callingAppName;
030:
031:            private Integer callingAppMode;
032:
033:            public void invokeApplication(WMSessionHandle shandle, long handle,
034:                    WMEntity appInfo, WMEntity toolInfo,
035:                    String applicationName, String procInstId, String assId,
036:                    AppParameter[] parameters, Integer appMode)
037:                    throws ApplicationNotStarted, ApplicationNotDefined,
038:                    ApplicationBusy, ToolAgentGeneralException {
039:
040:                super 
041:                        .invokeApplication(shandle, handle, appInfo, toolInfo,
042:                                applicationName, procInstId, assId, parameters,
043:                                appMode);
044:
045:                try {
046:                    status = APP_STATUS_RUNNING;
047:
048:                    String extAttribs = (String) parameters[0].the_value;
049:                    readParamsFromExtAttributes(extAttribs);
050:
051:                    // System.out.println("Calling "+taClass+" tool agent");
052:
053:                    Class cls = null;
054:
055:                    try {
056:                        cls = Class.forName(taClass);
057:                    } catch (ClassNotFoundException cnfe1) {
058:                        cls = ToolAgentLoader.load(cus, taClass);
059:                    }
060:
061:                    ToolAgent ta = (ToolAgent) cls.newInstance();
062:                    ta.configure(cus);
063:
064:                    // try to connect to the tool agent
065:                    WMSessionHandle taShandle;
066:                    try {
067:                        taShandle = ta.connect(this .wmci);
068:                    } catch (org.enhydra.shark.api.internal.toolagent.ConnectFailed cf) {
069:                        cus.error(shandle,
070:                                "Default Tool Agent - connection to Tool agent "
071:                                        + taClass + " failed !");
072:                        throw cf;
073:                    }
074:                    ta.invokeApplication(shandle, taShandle.getId(), appInfo,
075:                            toolInfo, callingAppName, procInstId, assId,
076:                            parameters, callingAppMode);
077:                    status = ta.requestAppStatus(shandle, taShandle.getId(),
078:                            toolInfo, procInstId, assId, parameters);
079:                    // System.out.println("DTA finished execution");
080:                    ta.disconnect(taShandle);
081:
082:                } catch (ClassNotFoundException cnf) {
083:                    cus.error(shandle, "DefaultToolAgent - application "
084:                            + appName
085:                            + " terminated incorrectly, can't find class: "
086:                            + cnf);
087:                    throw new ApplicationNotDefined("Can't find class "
088:                            + taClass, cnf);
089:                } catch (NoClassDefFoundError ncdfe) {
090:                    cus
091:                            .error(
092:                                    shandle,
093:                                    "DefaultToolAgent - application "
094:                                            + appName
095:                                            + " terminated incorrectly, can't find class definition: "
096:                                            + ncdfe);
097:                    throw new ApplicationNotDefined("Class " + appName
098:                            + " can't be executed", ncdfe);
099:                } catch (Throwable ex) {
100:                    // ex.printStackTrace();
101:                    cus.error(shandle,
102:                            "DefaultToolAgent - can't execute tool agent class "
103:                                    + taClass + " - application " + appName
104:                                    + " terminated incorrectly: " + ex);
105:                    status = APP_STATUS_INVALID;
106:                    if (ex instanceof  ToolAgentGeneralException) {
107:                        throw (ToolAgentGeneralException) ex;
108:                    } else if (ex instanceof  ApplicationNotStarted) {
109:                        throw (ApplicationNotStarted) ex;
110:                    } else if (ex instanceof  ApplicationNotDefined) {
111:                        throw (ApplicationNotDefined) ex;
112:                    } else if (ex instanceof  ApplicationBusy) {
113:                        throw (ApplicationBusy) ex;
114:                    } else {
115:                        throw new RootError("Unexpected error", ex);
116:                    }
117:                }
118:            }
119:
120:            public String getInfo() throws ToolAgentGeneralException {
121:                String i = "It is used to execute other tool agents based on XPDL extended attributes"
122:                        + "\nof appropriate Application definition. It is called by kernel if there are"
123:                        + "\nno mapping information for some XPDL Application definition";
124:                return i;
125:            }
126:
127:            protected ExtendedAttributes readParamsFromExtAttributes(
128:                    String extAttribs) throws Exception {
129:                String oldAppName = appName;
130:                Integer oldAppMode = appMode;
131:                ExtendedAttributes eas = super 
132:                        .readParamsFromExtAttributes(extAttribs);
133:                callingAppName = appName;
134:                callingAppMode = appMode;
135:                appName = oldAppName;
136:                appMode = oldAppMode;
137:                ExtendedAttribute ea = eas
138:                        .getFirstExtendedAttributeForName(TOOL_AGENT_CLASS_EXT_ATTR_NAME);
139:                if (ea != null) {
140:                    taClass = ea.getVValue();
141:                }
142:                return eas;
143:            }
144:
145:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.