Source Code Cross Referenced for TestSOAPHandler.java in  » ESB » celtix-1.0 » org » objectweb » celtix » systest » handlers » 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 » ESB » celtix 1.0 » org.objectweb.celtix.systest.handlers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.objectweb.celtix.systest.handlers;
002:
003:        import java.util.Map;
004:        import java.util.Set;
005:        import java.util.StringTokenizer;
006:
007:        import javax.xml.namespace.QName;
008:        import javax.xml.soap.SOAPBody;
009:        import javax.xml.soap.SOAPMessage;
010:        import javax.xml.ws.handler.MessageContext;
011:        import javax.xml.ws.handler.soap.SOAPHandler;
012:        import javax.xml.ws.handler.soap.SOAPMessageContext;
013:
014:        import org.w3c.dom.DOMException;
015:        import org.w3c.dom.Document;
016:        import org.w3c.dom.Node;
017:
018:        /**
019:         * Describe class TestSOAPHandler here.
020:         *
021:         *
022:         * Created: Fri Oct 21 13:24:05 2005
023:         *
024:         * @author <a href="mailto:codea@iona.com">codea</a>
025:         * @version 1.0
026:         */
027:        public class TestSOAPHandler<T extends SOAPMessageContext> extends
028:                TestHandlerBase implements  SOAPHandler<T> {
029:
030:            public TestSOAPHandler() {
031:                this (true);
032:            }
033:
034:            public TestSOAPHandler(boolean serverSide) {
035:                super (serverSide);
036:            }
037:
038:            // Implementation of javax.xml.ws.handler.soap.SOAPHandler
039:
040:            public final Set<QName> getHeaders() {
041:                return null;
042:            }
043:
044:            public String getHandlerId() {
045:                return "soapHandler" + getId();
046:            }
047:
048:            public final boolean handleMessage(T ctx) {
049:
050:                boolean continueProcessing = true;
051:
052:                try {
053:                    methodCalled("handleMessage");
054:                    printHandlerInfo("handleMessage", isOutbound(ctx));
055:                    Object b = ctx
056:                            .get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
057:                    boolean outbound = (Boolean) b;
058:                    SOAPMessage msg = ctx.getMessage();
059:
060:                    if (isServerSideHandler()) {
061:                        if (outbound) {
062:                            continueProcessing = true;
063:                        } else {
064:                            continueProcessing = getReturnValue(outbound, ctx);
065:                            if (!continueProcessing) {
066:                                outbound = true;
067:                            }
068:                        }
069:
070:                        if (outbound) {
071:                            try {
072:                                // append handler id to SOAP response message 
073:                                SOAPBody body = msg.getSOAPBody();
074:                                Node resp = body.getFirstChild();
075:
076:                                if (resp.getNodeName().contains("pingResponse")) {
077:                                    Node child = resp.getFirstChild();
078:                                    Document doc = resp.getOwnerDocument();
079:                                    Node info = doc.createElementNS(child
080:                                            .getNamespaceURI(), child
081:                                            .getLocalName());
082:                                    info.setPrefix("ns4");
083:                                    info.appendChild(doc
084:                                            .createTextNode(getHandlerId()));
085:                                    resp.appendChild(info);
086:                                    msg.saveChanges();
087:                                }
088:                            } catch (DOMException e) {
089:                                e.printStackTrace();
090:                            }
091:                        } else {
092:                            getHandlerInfoList(ctx).add(getHandlerId());
093:                        }
094:                    }
095:                } catch (Exception e) {
096:                    e.printStackTrace();
097:                }
098:                return continueProcessing;
099:            }
100:
101:            public final boolean handleFault(T ctx) {
102:                methodCalled("handleFault");
103:                printHandlerInfo("handleFault", isOutbound(ctx));
104:                return true;
105:            }
106:
107:            public final void init(final Map map) {
108:                methodCalled("init");
109:
110:            }
111:
112:            public final void destroy() {
113:                methodCalled("destroy");
114:            }
115:
116:            public final void close(MessageContext messageContext) {
117:                methodCalled("close");
118:            }
119:
120:            private boolean getReturnValue(boolean outbound, T ctx) {
121:
122:                if (outbound) {
123:                    return true;
124:                }
125:
126:                boolean ret = true;
127:                try {
128:                    SOAPMessage msg = ctx.getMessage();
129:                    SOAPBody body = msg.getSOAPBody();
130:
131:                    if (body.getFirstChild().getFirstChild() == null) {
132:                        return true;
133:                    }
134:
135:                    Node commandNode = body.getFirstChild().getFirstChild()
136:                            .getFirstChild();
137:                    String arg = commandNode.getNodeValue();
138:                    String namespace = body.getFirstChild().getFirstChild()
139:                            .getNamespaceURI();
140:
141:                    StringTokenizer strtok = new StringTokenizer(arg, " ");
142:                    String hid = strtok.nextToken();
143:                    String direction = strtok.nextToken();
144:                    String command = strtok.nextToken();
145:
146:                    if (getHandlerId().equals(hid)
147:                            && "inbound".equals(direction)) {
148:                        if ("stop".equals(command)) {
149:
150:                            // remove the incoming request body.
151:                            Document doc = body.getOwnerDocument();
152:                            // build the SOAP response for this message 
153:                            //
154:                            Node wrapper = doc.createElementNS(namespace,
155:                                    "pingResponse");
156:                            wrapper.setPrefix("ns4");
157:                            body.removeChild(body.getFirstChild());
158:                            body.appendChild(wrapper);
159:
160:                            for (String info : getHandlerInfoList(ctx)) {
161:                                // copy the the previously invoked handler list into the response.  
162:                                // Ignore this handlers information as it will be added again later.
163:                                //
164:                                if (!info.contains(getHandlerId())) {
165:                                    Node newEl = doc.createElementNS(namespace,
166:                                            "HandlersInfo");
167:                                    newEl.setPrefix("ns4");
168:                                    newEl.appendChild(doc.createTextNode(info));
169:                                    wrapper.appendChild(newEl);
170:                                }
171:                            }
172:                            ret = false;
173:                        } else if ("throw".equals(command)) {
174:                            //throwException(strtok.nextToken());
175:                        }
176:                    }
177:
178:                } catch (Exception e) {
179:                    e.printStackTrace();
180:                }
181:
182:                return ret;
183:            }
184:
185:            public String toString() {
186:                return getHandlerId();
187:            }
188:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.