Source Code Cross Referenced for WSIFInteraction.java in  » Testing » mockrunner-0.4 » com » mockrunner » connector » 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 » Testing » mockrunner 0.4 » com.mockrunner.connector 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.mockrunner.connector;
002:
003:        import java.lang.reflect.Method;
004:
005:        import javax.resource.ResourceException;
006:        import javax.resource.cci.InteractionSpec;
007:        import javax.resource.cci.Record;
008:
009:        /**
010:         * Implementor for IBM environments using the
011:         * Web Services Invocation Framework
012:         */
013:        public class WSIFInteraction implements  InteractionImplementor {
014:            private boolean enabled;
015:            private String isClassName;
016:            private String requestPartName;
017:            private Object requestPart;
018:            private String responsePartName;
019:            private Object responsePart;
020:
021:            /**
022:             * @param isClassName would be com.ibm.connector2.ims.ico.IMSInteractionSpec, com.ibm.connector2.cics.ECIInteractionSpec
023:             */
024:            public WSIFInteraction(String isClassName, String requestPartName,
025:                    Object requestPart, String responsePartName,
026:                    Object responsePart) {
027:                super ();
028:                this .isClassName = isClassName;
029:                this .requestPartName = requestPartName;
030:                this .requestPart = requestPart;
031:                this .responsePartName = responsePartName;
032:                this .responsePart = responsePart;
033:                this .enabled = true;
034:            }
035:
036:            /**
037:             * Enables this implementor.
038:             */
039:            public void enable() {
040:                this .enabled = true;
041:            }
042:
043:            /**
044:             * Disables this implementor. {@link #canHandle(InteractionSpec, Record, Record)}
045:             * always returns <code>false</code>, if this implementor is disabled.
046:             */
047:            public void disable() {
048:                this .enabled = false;
049:            }
050:
051:            public boolean canHandle(InteractionSpec interactionSpec,
052:                    Record actualRequest, Record actualResponse) {
053:                if (!enabled)
054:                    return false;
055:                Class specClass = getClassNamed(interactionSpec.getClass(),
056:                        isClassName);
057:                if (specClass != null) {
058:                    try {
059:                        Class wsifMessageClass = getClassNamed(actualRequest
060:                                .getClass(),
061:                                "org.apache.wsif.base.WSIFDefaultMessage");
062:                        Class wsifFormatPartClass = getClassNamed(requestPart
063:                                .getClass(),
064:                                "com.ibm.wsif.format.jca.WSIFFormatPartImpl");
065:                        if (wsifMessageClass != null
066:                                && wsifFormatPartClass != null) {
067:                            Class[] gopParams = new Class[1];
068:                            gopParams[0] = String.class;
069:                            Method gop = wsifMessageClass.getMethod(
070:                                    "getObjectPart", gopParams);
071:                            if (gop != null) {
072:                                Object[] gopArgs = new Object[1];
073:                                gopArgs[0] = requestPartName;
074:                                Object o1 = gop.invoke(actualRequest, gopArgs);
075:                                if (o1 != null) {
076:                                    Class[] elementsParams = new Class[0];
077:                                    Method elements = wsifFormatPartClass
078:                                            .getMethod("elements",
079:                                                    elementsParams);
080:                                    if (elements != null) {
081:                                        Object[] elementsArgs = new Object[0];
082:                                        Object map1 = elements.invoke(
083:                                                requestPart, elementsArgs);
084:                                        Object map2 = elements.invoke(o1,
085:                                                elementsArgs);
086:                                        if (map1.equals(map2)) {
087:                                            return true;
088:                                        }
089:                                    }
090:                                }
091:                            }
092:                        }
093:                    } catch (Exception exc) {
094:                        return false;
095:                    }
096:                }
097:                return false;
098:            }
099:
100:            /**
101:             * not implemented yet.
102:             */
103:            public Record execute(InteractionSpec interactionSpec,
104:                    Record actualRequest) throws ResourceException {
105:                throw new RuntimeException(
106:                        this .getClass().getName()
107:                                + " does not implement public Record execute(InteractionSpec, Record)");
108:            }
109:
110:            public boolean execute(InteractionSpec interactionSpec,
111:                    Record actualRequest, Record actualResponse)
112:                    throws ResourceException {
113:                if (!canHandle(interactionSpec, actualRequest, actualResponse))
114:                    return false;
115:                try {
116:                    Class wsifMessageClass = getClassNamed(actualRequest
117:                            .getClass(),
118:                            "org.apache.wsif.base.WSIFDefaultMessage");
119:                    Class[] sopParams = new Class[2];
120:                    sopParams[0] = String.class;
121:                    sopParams[1] = Object.class;
122:                    Method sop = wsifMessageClass.getMethod("setObjectPart",
123:                            sopParams);
124:                    if (sop != null) {
125:                        Object[] sopArgs = new Object[2];
126:                        sopArgs[0] = responsePartName;
127:                        sopArgs[1] = responsePart;
128:                        sop.invoke(actualResponse, sopArgs);
129:                        return true;
130:                    }
131:                } catch (Exception exc) {
132:                    ResourceException resExc = new ResourceException(
133:                            "execute() failed");
134:                    resExc.setLinkedException(exc);
135:                    throw resExc;
136:                }
137:                return false;
138:            }
139:
140:            /**
141:             * 
142:             * @param cl
143:             * @param className
144:             * @return null if not found
145:             */
146:            private Class getClassNamed(Class cl, String className) {
147:                if (cl == null) {
148:                    return null;
149:                }
150:                if (cl.getName().equals(className)) {
151:                    return cl;
152:                }
153:                Class[] classes = cl.getDeclaredClasses();
154:                for (int current = 0; current < classes.length; current++) {
155:                    Class c = classes[current];
156:                    if (className.equals(c.getName())) {
157:                        return c;
158:                    }
159:                }
160:                return getClassNamed(cl.getSuperclass(), className);
161:            }
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.