Source Code Cross Referenced for JavaClassToolAgent.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.lang.reflect.Method;
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:
013:        /**
014:         * Tool agent that executes special kind of java class.
015:         * 
016:         * @author Sasa Bojanic
017:         * @version 1.0
018:         */
019:        public class JavaClassToolAgent extends AbstractToolAgent {
020:
021:            private static final String EXECUTION_METHOD_NAME = "execute";
022:
023:            public void invokeApplication(WMSessionHandle shandle, long handle,
024:                    WMEntity appInfo, WMEntity toolInfo,
025:                    String applicationName, String procInstId, String assId,
026:                    AppParameter[] parameters, Integer appMode)
027:                    throws ApplicationNotStarted, ApplicationNotDefined,
028:                    ApplicationBusy, ToolAgentGeneralException {
029:
030:                super 
031:                        .invokeApplication(shandle, handle, appInfo, toolInfo,
032:                                applicationName, procInstId, assId, parameters,
033:                                appMode);
034:
035:                try {
036:                    status = APP_STATUS_RUNNING;
037:
038:                    if (appName == null || appName.trim().length() == 0) {
039:                        readParamsFromExtAttributes((String) parameters[0].the_value);
040:                    }
041:
042:                    ClassLoader cl = getClass().getClassLoader();
043:                    Class c = cl.loadClass(appName);
044:
045:                    // Get parameter types - ignore 1. param, these are ext.attribs
046:                    Class[] parameterTypes = null;
047:                    if (parameters != null) {
048:                        parameterTypes = new Class[parameters.length - 1];
049:                        for (int i = 1; i < parameters.length; i++) {
050:                            parameterTypes[i - 1] = AppParameter.class;
051:                        }
052:                    }
053:
054:                    Method m = c.getMethod(EXECUTION_METHOD_NAME,
055:                            parameterTypes);
056:
057:                    // invoke the method
058:                    AppParameter[] aps = new AppParameter[parameters.length - 1];
059:                    System.arraycopy(parameters, 1, aps, 0, aps.length);
060:                    m.invoke(null, aps);
061:                    status = APP_STATUS_FINISHED;
062:
063:                } catch (ClassNotFoundException cnf) {
064:                    cus.error(shandle, "JavaClassToolAgent - application "
065:                            + appName
066:                            + " terminated incorrectly, can't find class: "
067:                            + cnf);
068:                    throw new ApplicationNotDefined("Can't find class "
069:                            + appName, cnf);
070:                } catch (NoSuchMethodException nsm) {
071:                    cus.error(shandle, "JavaClassToolAgent - application "
072:                            + appName
073:                            + " terminated incorrectly, can't find method "
074:                            + EXECUTION_METHOD_NAME + " : " + nsm);
075:                    throw new ApplicationNotDefined("Class " + appName
076:                            + " doesn't have method " + EXECUTION_METHOD_NAME,
077:                            nsm);
078:                } catch (NoClassDefFoundError ncdfe) {
079:                    cus
080:                            .error(
081:                                    shandle,
082:                                    "JavaClassToolAgent - application "
083:                                            + appName
084:                                            + " terminated incorrectly, can't find class definition: "
085:                                            + ncdfe);
086:                    throw new ApplicationNotDefined("Class " + appName
087:                            + " can't be executed", ncdfe);
088:                } catch (Throwable ex) {
089:                    cus.error(shandle, "JavaClassToolAgent - application "
090:                            + appName + " terminated incorrectly: " + ex);
091:                    status = APP_STATUS_INVALID;
092:                    throw new ToolAgentGeneralException(ex);
093:                }
094:            }
095:
096:            public String getInfo(WMSessionHandle shandle)
097:                    throws ToolAgentGeneralException {
098:                String i = "This tool agent executes Java classes, by calling its static method called \"execute\"."
099:                        + "\nWhen calling this tool agent's invokeApplication() method, the application "
100:                        + "\nname parameter should be the full name of the class that should be executed "
101:                        + "\nby this tool agent (the classes had to be in the class path) "
102:                        + "\n"
103:                        + "\nThis tool agent is able to understand the extended attribute with the following name:"
104:                        + "\n     * AppName - value of this attribute should represent the class name to be executed"
105:                        + "\n"
106:                        + "\n NOTE: Tool agent will read extended attributes only if they are called through"
107:                        + "\n       Default tool agent (not by shark directly) and this is the case when information "
108:                        + "\n       on which tool agent to start for XPDL application definition is not contained in mappings";
109:                return i;
110:            }
111:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.